On Tue, Jul 29, 2008 at 3:48 PM, Ryan Ingram
On Tue, Jul 29, 2008 at 8:57 AM, Jefferson Heard
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.