evertedsphere / silica

optics for Haskell with the most amazing type errors you've seen
BSD 3-Clause "New" or "Revised" License
243 stars 7 forks source link

Suggestions for the "basics" module (for "beginners and people in a hurry") #1

Open mrkgnao opened 6 years ago

chris-martin commented 6 years ago

I think the Lens type needs to be introduced prior to the lens function, or else I have no idea what I'm reading: What is a lens, and thus why would I want to use this function to make one?

And, perhaps more ambitiously, to answer this question: If a lens is a getter and a setter, then why doesn't it just look like this?

data Lens s t a b =
  Lens
    { lensGet :: s -> a
    , lensSet :: s -> b -> t
    }
chris-martin commented 6 years ago

Perhaps there could be a section on "composing optics"? I'm not sure how much of that is simply "use (.)" or if there are other relevant combinators you need?

mrkgnao commented 6 years ago

When composing two dissimilar optics, you get the join of the two optic types, which needs explaining.