4 ms·
That's what I like about Haskell. Brilliant people writing really cool stuff. I'm constantly amazed by Haskell libraries!
by greg7mdp 10y ago
That's what I like about Haskell. Brilliant people writing really cool stuff. I'm constantly amazed by Haskell libraries!
- demilicious 10y agoAgreed. I've never felt an "in-over-my-head" feeling as strongly as when I first stumbled upon the Lens package docs on Hackage.
- cm3 10y agoThe idea behind lenses is simple, but I haven't used it yet. What's the complexity?
- DanWaterworth 10y agoThe lens library is more like a dialect of Haskell than a library.
- cm3 10y agoNot trying to sound snarky, serious question: Is it due to Edward's (over)use of the type system, making it fit (however complex) into the Haskell system? Could a more expressive system like Idris have avoided the complexity? If so, I'm certain there is a simple implementation of the lens idea that's much easier to understand and apply.
- danidiaz 10y agoThere's an alternative implementation based on profunctors, discussed here: https://pay.reddit.com/r/haskell/comments/4poiq5/phil_freeman_fun_with_profunctors/ https://pay.reddit.com/r/haskell/comments/4poiq5/phil_freema... "lens" can be complex, but it also makes an effort to fit well with the standard Foldable/Traversable/Applicative idioms of Haskell, and it can be seen as an extension of them, both in functionality and in nomenclature.
- tome 10y ago> Is it due to Edward's (over)use of the type system, making it fit (however complex) into the Haskell system? No, not at all. It fits extremely naturally into Haskell's typesystem. The fit is so natural that it's quite astonishing they weren't discovered earlier.
- tikhonj 10y agoNo. It's more the sheer breadth and scope of the vocabulary lens develops. It has a ton of operations and abstractions, all written in a distinctly "lensy" style with their own idioms. They fit together beautifully, but are distinct enough from normal Haskell style that learning them takes additional effort. If you just had a small subset of the library that only exposed, say, Lens, Traversal and Prism, it would be much more approachable—but would also miss out on much of what makes lens so universally useful. It wouldn't hit all the edge cases lens does and it wouldn't be "batteries included". You'd find yourself ultimately reinventing part of the other abstractions that lens has but, since you're doing it independently and ad-hoc, the result would be uglier.
- gh02t 10y ago> learning them takes additional effort. Do you have any recommendations on what might be a good read or project for learning Lens? I played around with it a couple times, but I could never find an introduction or anything that really let me get a grasp on their core concepts and use. I'm not looking so much for the mechanics of how to use them, but more of an overview of when and why I might want to use them.