Is it possible to resolve y
as a function of f
and x
, if the monads N
and M
are one-way?
x :: M (N X)
f :: X -> M (N Y)
-- pattern matching not allowed, one-way monads implied
y :: M (N Y)
y = _
Full definitions:
data X = X
data Y = Y
-- pattern matching not allowed, one-way monads implied
data M a = M a
data N a = N a
instance Functor M where
fmap = undefined
instance Applicative M where
pure = undefined
(<*>) = undefined
instance Monad M where
(>>=) = undefined
instance Functor N where
fmap = undefined
instance Applicative N where
pure = undefined
(<*>) = undefined
instance Monad N where
(>>=) = undefined
x :: M (N X)
x = undefined
f :: X -> M (N Y)
f = undefined
-- pattern matching not allowed, one-way monads implied
y :: M (N Y)
y = _
My intuition is that this is not generally possible, and that it is related to the problem that monad transformers solve, but I am not sure.