Open BebeSparkelSparkel opened 1 month ago
It seems like Cofunctor may work here.
Indeed that's why I added Cofunctor
, though I wonder if I really need the generality as opposed to just a mapping from a -> Maybe b
Actually, I have not been able to get Cofunctor
to work correctly with this. It seems like I need
class Cotrans p m | p -> m where colift :: (a -> m b) -> p b c -> p a c
newtype Fwd m u v = Fwd {unFwd :: m v}
instance Cotrans (Fwd m) m where
colift = const coerce
newtype Bwd m u v = Bwd {unBwd :: u -> m v}
instance Monad m => Cotrans (Bwd m) m where
colift f = Bwd . (>=>) f . unBwd
I'm not sure if this exists somewhere. Have you seen this before?
I found in biparsing that a monadic
lmap
was very useful.Is there an
lmapM :: (a -> m b) -> t m b c -> t m a c
?