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?
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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?
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 genericmap
function (as well as actually providing the lens combinators too), so in practice I just use that library if I want to use lenses.