Git Product home page Git Product logo

idris2-lens's Introduction

Profunctor Optics in Idris2

This package provides utilities for working with lenses, prisms, traversals, and other optics in Idris. This library uses profunctor optics.

Comparison to Monocle

Monocle is another Idris 2 library for lenses. That library represents lenses using a datatype, which is often less efficient at run-time, but results in better error messages and is generally simpler to understand.

Comparisons to Non-Idris Libraries

This library is inspired by the Haskell libraries lens, optics and fresnel, along with the Purescript library purescript-profunctor-lenses. Different design decisions are taken from each library.

Like lens, this library comes "batteries-included" with many useful lenses for common types. It also includes the many lens operators. Like optics, fresnel and purescript-profunctor-lenses, but unlike lens, this library uses profunctor optics as opposed to van Laarhoven optics.

Like lens and fresnel, this library defines optics through type synonyms and uses the (.) operator to compose them. Like fresnel, and unlike lens, this library goes to some effort to ensure that type signatures and error messages are understandable to some degree.

This library's optics hierarchy is most similar to that of fresnel, though it also includes the Equality optic from lens. Unlike fresnel, this library also supports indexed optics.

Installation

This package depends on the profunctors package. It can be installed from pack or from its GitHub repository here.

To install using idris2 directly:

git clone https://github.com/kiana-S/idris2-lens
cd idris2-lens
idris2 --install lens.ipkg

Or you can install using pack:

pack install lens

Thanks

Special thanks to Stefan Höck for assistance with writing elaboration scripts.

idris2-lens's People

Contributors

kiana-s avatar lomisk avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

crumbtoo

idris2-lens's Issues

Derivation of lenses fails with `%prefix_record_projections off`

With prefix_record_projections disabled, deriving Lenses fails with during
reflection, due to the unexpected absence of unprefixed projections.

MWE

module Test
--------------------------------------------------------------------------------
import Control.Lens
import Derive.Lens
import Derive.Prelude
--------------------------------------------------------------------------------
%default total
%prefix_record_projections off
%language ElabReflection
--------------------------------------------------------------------------------

public export
record Person where
  constructor MkPerson
  name : String
  age  : Nat

-- throws error during reflection
%runElab derive "Person" [Lenses]

As far as I can tell, this is trivially fixed by simply using the prefixed projections, as they are always present regardless of prefix_record_projections.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.