Control.Monad.Morph
includes
class MFunctor t where
hoist :: Monad m => (forall a. m a -> n a) -> t m b -> t n b
As far as I can tell, none of the included instances use the Monad m
constraint. How might one do so? Are there valid instances that use the constraint (it's a bit hard for me to imagine how, given that hoist id = id
)? What's the significance of the constraint being on m
and not n
?
Control.Monad.Morph
is a spinoff from pipes, so I'd guess it's there because the MFunctor
instance for Proxy
needs it... And sure enough it's used there.
instance MFunctor (Proxy a' a b' b) where hoist nat p0 = go (observe p0) where go p = case p of Request a' fa -> Request a' (\a -> go (fa a )) Respond b fb' -> Respond b (\b' -> go (fb' b')) M m -> M (nat (m >>= \p' -> return (go p'))) Pure r -> Pure r
I don't think it's needed though. m >>= return . f
is fmap f m
. It probably should be a Functor
constraint and that code predates the implementation of the monad-applicative proposal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With