[Haskell-cafe] Very simple parser
Gregory Propf
gregorypropf at yahoo.com
Mon Jul 2 20:33:12 EDT 2007
This was a bit baffling too. It appears that there's an implied argument to runTick. This also works and makes it more explicit. I suppose the compiler just works out that the only place to put the 'n' is after tick.
runTick :: Int -> (String,Int)
runTick n = runState tick n
----- Original Message ----
From: Arie Peterson <ariep at xs4all.nl>
To: haskell-cafe at haskell.org
Sent: Monday, July 2, 2007 4:51:59 PM
Subject: Re: [Haskell-cafe] Very simple parser
To get you going, start with the example from the documentation, modified
slightly:
> tick :: State Int String
> tick = do
> n <- get
> put (n+1)
> return (show n)
If you want to actually run 'tick', use the 'runState' function:
> runTick :: Int -> (String,Int)
> runTick = runState tick
____________________________________________________________________________________
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070702/3a4fe967/attachment.htm
More information about the Haskell-Cafe
mailing list