Giter Site home page Giter Site logo

Constraints should be open about optics HOT 6 OPEN

treeowl avatar treeowl commented on August 14, 2024
Constraints should be open

from optics.

Comments (6)

phadej avatar phadej commented on August 14, 2024

Optics hierarchy is closed in optics. This a design choice (somewhat indirectly mentioned in https://hackage.haskell.org/package/optics-0.4.1/docs/Optics.html#g:4, opaque design leads to closed hierarchy). And in fact OpticKind could be a data (i.e. closed kind) IMO, but we decided to have OpticKind = Type for now (#58), because GHC prints ugly ticks for promoted types. (We might revisit that once https://gitlab.haskell.org/ghc/ghc/-/issues/20531 is implemented, optics being a motivation point).

from optics.

arybczak avatar arybczak commented on August 14, 2024

To be fair, Constraints being open wouldn't change anything in the past because we relied on JoinKinds being a closed type family. But now that it's a class, if the Constraints and EliminationForms are made open, then IIUC it would be possible for a third party to add a new optic kind 🤔

from optics.

phadej avatar phadej commented on August 14, 2024

The addition is not very compositional though. User A can add their optic easily, and User B can add theirs, but if C want to use both, they will need to make A and B to talk to each other.

And you cannot add something in between, like Traversal1.

from optics.

treeowl avatar treeowl commented on August 14, 2024

@phadej, why can't you add something in between? The diamond problem is ... annoying.

from optics.

phadej avatar phadej commented on August 14, 2024

why can't you add something in between?

You are right, maybe Traversal1 one can be added in, as we don't over-approximate JoinKinds, i.e. it's a "Join" i.e. least upper bound of known optics. (I was thinking about lens, where Prism and Lens composition is Traversal, and not AffineTraversal, as there isn't AffineTraversal in lens).

(EDIT: this is another example of non-compositionality, all additions have to preserve the "leastness" of upper bounds in JoinKinds; have to consider the global structure to keep it sane)

from optics.

treeowl avatar treeowl commented on August 14, 2024

In principle, I think it should be possible to do much more with in-betweens than lens can, through suitable fudging of Is.

from optics.

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.