-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eventual fate of the Dhall.Optics module #998
Comments
Let's try getting the combinators into |
I had a brief look at this and the sticking point is that half the combinators use profunctors, directly or indirectly. |
@quasicomputational: I don't think we need |
I'm closing this unless somebody volunteers to implement this. I personally don't mind keeping the |
I am interested in a proper solution to this issue; Reopening. |
This commit adds the following new optics to the microlens package: * `mapMOf`, `rewriteMOf`, `transformMOf` These functions allow you to map/rewrite/transform a value using a lens a monadic action. * `anyOf`, `allOf`, `noneOf` In addition to those folds the `foldMapOf` function which was already present in the internal module is exposed by the public API. * `cosmosOf` Provided a traversal of the immediate children of a value, transitively traverse a children and the value itself. In addition to that the `Zoomed` type family is exposed by the public API of the microlens-mtl package. The changes were motivated by an issue of the Dhall project; See dhall-lang/dhall-haskell#998
I'm not familiar with the Haskell ecosystem and with the ways the Haskell community is doing things with libraries and modules. I'm only familiar with the idioms of pure functional programming to the extend it is language-independent. So let me just say that in my view, libraries implementing profunctors, monoids, optics, etc. are specified uniquely through the mathematical properties of those data types. There should be no difference between any implementations of monoids or profunctors; there can be only one implementation. So, a program could depend on these libraries or copy their definitions; there won't be any significant difference, because the mathematical definitions of profunctors, monoids, lenses, etc. will literally never be revised, and the implementation follows automatically from the mathematical defiitions. An exception would be if a library uses some complicated low-level code for better performance but still exposes the same high-level interface. It's hard for me to imagine how this could be the case for profunctors or lenses though. |
This commit adds the following new optics to the microlens package: * `mapMOf`, `rewriteMOf`, `transformMOf` These functions allow you to map/rewrite/transform a value using a lens a monadic action. * `anyOf`, `allOf`, `noneOf` In addition to those folds the `foldMapOf` function which was already present in the internal module is exposed by the public API. * `cosmosOf` Provided a traversal of the immediate children of a value, transitively traverse a children and the value itself. In addition to that the `Zoomed` type family is exposed by the public API of the microlens-mtl package. The changes were motivated by an issue of the Dhall project; See dhall-lang/dhall-haskell#998
I think it's a bit silly for
dhall
to have its own mini-lens
- it's a violation of the separation of concerns. At the same time, the combinators are useful, and avoiding a dependency onlens
does have value.Possible directions:
Do nothing; the situation isn't terrible. A few combinators being copy-pasted isn't the worst thing.
Bite the bullet and incur a
lens
dependency.dhall
is already a heavy package and I think thelens
dependency only amounts to a few additional packages (there's already a dependency onprofunctors
, though not onsemigroupoids
), thoughlens
itself is a meaty compile. The upside is getting to use all the fun things inlens
.Try to get the combinators upstreamed into
lens-family-core
, which is already a dependency. I don't know how receptive that package is to implementing combinators fromlens
.Move to
microlens
instead oflens-family-core
. This package definitely does accept random combinators fromlens
, and it's similarly lightweight. I don't know whetherlens-family-core
might have some countervailing advantage, though.The text was updated successfully, but these errors were encountered: