3 ms·
Oh the overview page is even worse for readability _1 :: Lens' (a,b) a is used immediately after set :: Lens' a b -> b -> a -> a which completely messes
by spion 4y ago
Oh the overview page is even worse for readability
_1 :: Lens' (a,b) a
is used immediately after
set :: Lens' a b -> b -> a -> a
which completely messes with anyone who's mind works in a way that makes it extremely difficult when symbols are immediately reused with completely different meanings.
To summarize, Haskell documentation communication is biased against linguistically clear explanations and towards mathematically precise, symbolic "explanation", and those who are used to unnecessarily struggling with the latter style due to their math background are more likely to "make it".
- Karrot_Kream 4y agoThe Lens library sucks even if you're fluent in advanced math and Haskell. In practice when I have to use Lens (usually with JSON), I just code golf it until it works because it's so damn impenetrable.
- axman6 4y agoI couldn’t agree with this opinion less - lens is incredibly elegant, and very consistent. It is a DSL, and you need to spend some time learning the domain, but once you do you’ll find it hard to live without it. If that’s the way you use the library then you haven’t spent any time to learn how to use it.
- solomonb 4y agoIf you apply `_1` to `set` then it specializes to `set _1 :: a -> (a, b) -> (a, b)`. Yes its confusing. It sometimes helps to give longer variables: _1 :: Lens' (fst, snd) fst set :: Lens' structure focus -> focus -> structure -> structure set _1 :: fst -> (fst, snd) -> (fst, snd) You are bumping up against the severe amount of polymorphism at play in the lens library. This makes it hard to build a mental model but is a tremendous source of expressiveness and utility.