Polymorphic lenses


#1

I’m working through the book “Lenses for the Mere Mortal.”

Are there polymorphic lenses, such that I can define a lens ‘_position’ that operates on any data type that has a ‘position’ field?


#2

Is Data.Lens.Record perhaps what you’re after?


#3

Thanks, that looks good. By any chance can you explain how that lens can be “type-changing”? How do I implement the algorithm for the type change? There’s not much of an example in the documentation.


#4

Wait I think I figured it out. It will change type based on the function provided to ‘over’ from Data.Lens.


#5

@mike1127 I’m still gradually adding documentation to Data.Lens. If you want help documenting Data.Lens.Record or want to give me examples to use in its documentation, give me a shout. (I’ve never used it.) marick@exampler.com