[Haskell-cafe] Problem compiling a CGI script that needs to write to file during its execution

Luke Palmer lrpalmer at gmail.com
Tue Jul 29 18:08:07 EDT 2008


On Tue, Jul 29, 2008 at 3:48 PM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> 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.

Probably:

  writeFile :: FilePath -> String -> IO ()
  liftM writeFile :: Monad m => m FilePath -> m (String -> IO ())
  liftM writeFile "path"

Will unify "path"::[Char]  with m Filepath.  Instantiate m to [] (by
head matching), but [Char] does not match [Filepath] (= [String]),
giving the error the OP mentioned.


More information about the Haskell-Cafe mailing list