[Haskell-beginners] Very basic question on monads

blackcat at pro-ns.net blackcat at pro-ns.net
Wed Feb 23 06:30:18 CET 2011


I'm working through the "Write Yourself a Scheme" wikibook and having 
trouble with one of the exercises.  For the function parseNumber :: 
Parser LispVal, both

parseNumber = liftM (Number . read) $ many1 digit
parseNumber' = do digits <- many1 digit
                  return $ (Number . read) digits

work.  But

parseNumber'' = many1 digit >>= liftM read >>= liftM Number

complains "couldn't match expected type Char against inferred type 
[Char]".  Is liftM engaging the list monad?  How do I fix this?




More information about the Beginners mailing list