I'm trying to make a function that uses another monadic function inside a preexisting monad, and I'm having trouble.<br>Basically my problem boils down to this. I have three monadic functions with the following types:<br>
f :: A -> M B<br>g :: B -> N C<br>h :: C -> M D<br>(M and N are in the monad class)<br>I want a function i where <br>i :: A -> M (N D)<br><br>the best I can come up with is:<br>i :: A -> M (N (M D))<br>i a = liftM (liftM h) =<< (return . g) (f a)<br>
<br>I'm starting to feel pretty sure that what I'm going for is impossible. Is this the case?