unliftM

Ashley Yakeley ashley@semantic.org
Fri, 23 Feb 2001 00:32:45 -0800


At 2001-02-22 20:54, Julian Assange wrote:

>Is there a standard construct for something of this ilk:
>
>unliftM :: Monad m a -> a

Assuming you mean "unliftM :: (Monad m) => m a -> a", I certainly hope 
not!!!

>In this case, I need to construct a localised stateful computation
>
>comp :: Int -> Int
>comp n = unliftM (do x <- ... return x)

The correct way to express this is:

comp :: Int -> IO Int
comp n = (do x <- ... return x)

I think of "IO Int" meaning "instructions for an imperative action, that, 
if performed, would return an Int". That's quite different from an Int.

-- 
Ashley Yakeley, Seattle WA
Almost empty page: <http://semantic.org/>