[Haskell-cafe] Problem compiling a CGI script that needs to write
to file during its execution
Ryan Ingram
ryani.spam at gmail.com
Tue Jul 29 17:48:54 EDT 2008
On Tue, Jul 29, 2008 at 8:57 AM, Jefferson Heard
<jefferson.r.heard at gmail.com> wrote:
> I tried using liftM on writeFile, but it then complained that "newanns"
> was a string instead of a list of strings, which I don't understand at all.
liftM isn't what you think it is.
> liftM :: (a -> b) -> (m a -> m b)
which is doing something weird depending how you inserted it:
> liftM (writeFile "x") :: Monad m => m String -> m (IO ())
which could theoretically have m get forced to be a list as the
typechecker tries to figure out how to decipher this mess...
> liftM (writeFile "x") :: [String] -> [IO ()]
or something else weird.
You are looking for either lift or liftIO, from Control.Monad.Trans
> lift :: (Monad m, MonadTrans t) => m a -> t m a
> liftIO :: MonadIO m => IO a -> m a
-- ryan
More information about the Haskell-Cafe
mailing list