
4 Apr
2009
4 Apr
'09
7:52 a.m.
Michael Roth wrote:
Hello list,
maybe I'm just stupid, I'm trying to do something like this:
Ciao Michael, As an alternative solution to Creighton's: import Control.Monad.List foobar :: ListT IO Int foobar = do a <- ListT . return $ [1,2,3] b <- ListT . return $ [4,5,6] liftIO $ putStrLn $ (show a) ++ " " ++ (show b) return (a+b) main = do sums <- runListT foobar print sums For the expression ListT . return $ [1,2,3] of type ListT IO Int, the return inferred is: return: a -> IO a return [1,2,3] = IO [1,2,3] and then you wrap the IO [] with the ListT newtype constructor. Paolo