Coder Social home page Coder Social logo

Type operator constructors for Simple about lens HOT 9 CLOSED

ekmett avatar ekmett commented on September 22, 2024
Type operator constructors for Simple

from lens.

Comments (9)

ekmett avatar ekmett commented on September 22, 2024

I'm somewhat torn about these.

Just writing down the list of issues and thoughts I had had about these before

The nice thing about the existing operators that we do have is that they mostly have a consistent set of semiotics, but that symbology doesn't transfer to these.

This also introduces a new extension into the mix. I don't think we had any type operators in lens before this. ;)

I had also consciously left off infix versions because they pessimized the use of the more correct 4 argument types for many lenses.

That and I was hoping that if I put it off long enough 7.6 would be current enough that I could use aliases that didn't start with :, e.g.

type a <-> b = Simple Iso a b

But, all that said, it looks like the next platform is probably going to ship with 7.4.2, so that is a dead dream.

I can probably be talked into a subset of them. Let me chew on names for a bit. =/

The :-> operator is at least consistent with all the other lens libraries and might help people with the transition.

The Traversal operator there kind of gives me pause though. :=> might be a better "heavy lens" visual for it.

Maybe if we just did Traversal and Lens for now?

Re: SimpleIndexedLens that wouldn't work as an SimpleIndexedLens and its ilk` takes 3 arguments.

from lens.

ekmett avatar ekmett commented on September 22, 2024

(and probably Iso)

from lens.

ekmett avatar ekmett commented on September 22, 2024

We could probably do some kind of evil a:@Int-> b for indexed lenses, using

infixr 0 :@
type family a :@ b
type instance a :@ (i -> c) = SimpleIndexedLens i a c

but it hardly seems worth it and doesn't generalize. ;)

from lens.

ekmett avatar ekmett commented on September 22, 2024

Closing this out as 'good enough', but feel free to re-open it.

from lens.

mgsloan avatar mgsloan commented on September 22, 2024

Yup. I picked operators that start with colon for backwards compatibility
sake. It's unfortunate that it'll be a while before we can assume ghc 7.6
as a bare minimum - it does kinda suck that we either choose operators now
that start with a colon or wait for the new type operators behavior to
become standard.

At once, I really like :=> for traversal, because it's just like lens :->
but with multiple paths. We wouldn't be able to use "->" and "=>" anyway,
for obvious reasons, so this could be a reason to justify the colon. On
the other hand, I can also see people being initially confused about ":=>"
due to its similarity to the builtin "=>".

So, my vote is for having two type operators - ":->" and ":=>"

On Tue, Sep 25, 2012 at 8:23 AM, Edward A. Kmett
[email protected]:

Closing this out as 'good enough', but feel free to re-open it.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-8858196.

from lens.

ekmett avatar ekmett commented on September 22, 2024

I added :->, :=>, :<-> and pushed out 3.0 (to get zippers into circulation) just a little bit ago.

from lens.

mgsloan avatar mgsloan commented on September 22, 2024

Great!

Thanks for adding those! I think they will make the Lens DSL better,
because I'd like to use the type signatures of the declarations to
determine whether the lens or iso transformation is used. This means I can
have the following:

type a :->: b = a -> b
type a :=>: b = a -> [b]
type a :<->: b = a -> b

Which allows the [d| |] quote to typecheck, while providing information to
TH that distinguishes between lenses and isos. I'm not sure if this is an
approach that's been used before - you can pass in arbitrary configuration
into TH - and make the types work out - by providing the appropriate type
synonyms. Could be an interesting thing to consider in general. It
resolves much of people's problems with using TH for DSLs (obscure errors).

-Michael

On Tue, Sep 25, 2012 at 10:35 AM, Edward A. Kmett
[email protected]:

I added :->, :=>, :<-> and pushed out 3.0 (to get zippers into
circulation) just a little bit ago.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-8863004.

from lens.

mgsloan avatar mgsloan commented on September 22, 2024

I'm not sure if it would be good to encourage people to mix the definitions of their lenses, isos, and traversals.

At once, it could make the API really small:

lenq :: DecsQ -> DecsQ
lense, isoe, traversale :: ExpQ -> ExpQ

from lens.

ekmett avatar ekmett commented on September 22, 2024

heh, lense is cute.

from lens.

Related Issues (20)

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.