You can do this if D -> M (N D) is a monad itself.
I suggest you study monad transformers - may be it's what you really
want.
On 10 Jul 2009, at 19:34, Job Vranish wrote:
I'm trying to make a function that uses another monadic function
inside a preexisting monad, and I'm having trouble.
Basically my problem boils down to this. I have three monadic
functions with the following types:
f :: A -> M B
g :: B -> N C
h :: C -> M D
(M and N are in the monad class)
I want a function i where
i :: A -> M (N D)
the best I can come up with is:
i :: A -> M (N (M D))
i a = liftM (liftM h) =<< (return . g) (f a)
I'm starting to feel pretty sure that what I'm going for is
impossible. Is this the case?
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe