i am missing something really trivial with parsec

number = do { num <- natural ; return $ num } main = do txt <- hGetContents stdin print $ parse number "stdin" txt why doesn't that work?

I don't know, but:
number
-- definition
= do { num <- natural ; return $ num }
-- desugar
= natural >>= \num -> return $ num
-- apply ($)
= natural >>= \num -> return num
-- eta elimination (f == \x -> f x)
= natural >>= return
-- monad law
= natural
(modulo monomorphism restriction, since number doesn't take any arguments
and doesn't have a type signature)
-- ryan
On Tue, Sep 29, 2009 at 12:54 AM, Anatoly Yakovenko
number = do { num <- natural ; return $ num } main = do txt <- hGetContents stdin print $ parse number "stdin" txt
why doesn't that work? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Tue, Sep 29, 2009 at 12:54:21AM -0700, Anatoly Yakovenko wrote:
number = do { num <- natural ; return $ num } main = do txt <- hGetContents stdin print $ parse number "stdin" txt
why doesn't that work?
Could you be a little more specific? What are you expecting to happen, and what happens instead/what error message do you get? -Brent
participants (3)
-
Anatoly Yakovenko
-
Brent Yorgey
-
Ryan Ingram