You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Composition section of the Lenses guide, there's this example:
(* Lens<'a,'b> -> 'a -> 'b *)letget(g,_)=fun a -> g a
(* Lens<'a,'b> -> 'b -> 'a -> 'a *)letset(_,s)=fun b a -> s b a
Could (and should?) this be simplified to:
(* Lens<'a,'b> -> 'a -> 'b *)letget(g,_)= g
(* Lens<'a,'b> -> 'b -> 'a -> 'a *)letset(_,s)= s
The latter code snippet is functionally the same as the former. Is there any reason why the first code snippet is used instead of the second? Perhaps I'm missing the point it's trying to make.
The text was updated successfully, but these errors were encountered:
You're absolutely right that the code could be simplified in that way - it is just function application after all. Although it's a while ago, I think the reason I wrote it this way was to effectively make that explicit - there's no magic other than normal function application, a lens is simply a pair of functions. And hopefully that fits in well with the progression of building up a lens. It might be good to add your simplification as an aside though, for those who spot it!
In the Composition section of the Lenses guide, there's this example:
Could (and should?) this be simplified to:
The latter code snippet is functionally the same as the former. Is there any reason why the first code snippet is used instead of the second? Perhaps I'm missing the point it's trying to make.
The text was updated successfully, but these errors were encountered: