forcing IO operations

Andre W B Furtado awfurtado@uol.com.br
Thu, 21 Feb 2002 01:18:21 -0300


[answering myself...]


> > >liftIOtoMyMonad_     :: IO () -> MyMonad ()
> > >liftIOtoMyMonad_ m   = liftIOtoMyMonad' (const m) ()
>
> I'm having problems compiling this one: "The last statement in a 'do'
> construct must be an expression"

The problem is not related with liftIOtoMyMonad_ , but with liftIOtoMyMonad
and liftIOtoMyMonad'. I think its an identation problem. Re-writing these
funcions as follows solves the problem:

>liftIOtoMyMonad'     :: (a -> IO ()) -> a -> MyMonad ()
>liftIOtoMyMonad' p q =
>     StateMonad $ \s -> (do p q
>                            return ((),s))
>
>liftIOtoMyMonad      :: IO a -> MyMonad a
>liftIOtoMyMonad p    =
>     StateMonad $ \s -> (do y <- p
>                            return (y,s))


At least by now, all the ideas are working very well... great help Jay,
thanks a lot!

-- Andre