How to involuntarily return a "Maybe" lens?

Maybe (Lens' ab) type type Maybe (Lens' ab) does not work, because Lens' is under a hood of type Rank-2, t be wrapped in a type constructor without the extension -XImpredicativeTypes (which is not supported in GHC).

So the best type is to give a function that morally would have a type

 foo :: A -> Maybe (Lens' BC) 

Perhaps it would be possible to postpone Maybe to continue

 foo' :: βˆ€ y . A -> (Lens' BC -> y) -> Maybe y 

but I don’t particularly like it.

+6
source share
1 answer

This is the Control.Lens.Reified module. It contains newtype wrappers for the lens hierarchy.

 foo :: A -> Maybe (ReifiedLens' BC) 
+7
source

Source: https://habr.com/ru/post/1013862/


All Articles