DEV Community

Discussion on: Grokking Lenses

Collapse
 
bytesource profile image
Bytesource

One follow up question: To implement generic get/view and set/setl funtions we'd need to use the FSharpPlus library, because F# doesn't have a Functor type and no generic 'map' function. Is that correct?

Collapse
 
choc13 profile image
Matt Thornton

Yeah that’s right. Strictly speaking we don’t have to use F#+, we could use SRTP ourselves and just make sure that the type being returned from the Lens has something like a Map member that obeys the Functor laws and use this same constraint on the get/view set/setl implementations. But F#+ gives us a generic map function (as well as actually providing the lens combinators too), so in practice I just use that library if I want to use lenses.