Possible Duplicate:
lenses, fclabels, data-accessor - which library for structure access and mutation is better
I'm going to use and learn a Lens package on my next Haskell project. I had almost decided on the Data.Lens
package when I found this post which mentions van Laarhoven Lenses in the Control.Lens
package.
I don't really understand the differences enough yet to decide which one to use. Which package would you suggest I learn/use on a real world project?
Thanks.
lenses, fclabels, data-accessor - which library for structure access and mutation is better
Control.Lens
is almost certainly what you want. Data.Lens
came first, and is simpler, but Control.Lens
has many advantages, and is being actively developed.
Other than lenses, Control.Lens
has many related types, like traversals (a traversal is like a lens that can refer to n values instead of just one), folds, read/modify-only lenses, indexed lenses, isomorphisms... It also comes with a much larger library of useful functions and predefined lenses for standard library types, Template Haskell to derive lenses, and a bunch of code for other things like generic zippers and uniplate-style generic traversal.
It's a big library -- you don't have to use all of it, but it's nice to have the thing you want already written.
The main advantage of Data.Lens
is that it's simpler, and as such doesn't require extensions beyond Haskell 98. But note that if you just want to export a Control.Lens
-style lens from a library, you can do it without leaving Haskell 98 -- in fact, without depending on the package at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With