[Haskell-cafe] newbie question on Parsers from "Programming In Haskell"

2007-06-04 Thread Juozas Gaigalas
Hello, I am a somewhat experienced programmer and a complete Haskell newbie, so I hope this is the correct ML for my question. I have decided to learn Haskell and started with Graham Hutton's book. Everything was going nicely until section 8.4, on sequencing functional parsers. I am trying to w

Re: [Haskell-cafe] newbie question on Parsers from "Programming In Haskell"

2007-06-04 Thread Alfonso Acosta
On 6/4/07, Juozas Gaigalas <[EMAIL PROTECTED]> wrote: Hello, I am a somewhat experienced programmer and a complete Haskell newbie, so I hope this is the correct ML for my question. I have decided to learn Haskell and started with Graham Hutton's book. Everything was going nicely until section

Re: [Haskell-cafe] newbie question on Parsers from "Programming In Haskell"

2007-06-04 Thread David House
On 04/06/07, Alfonso Acosta <[EMAIL PROTECTED]> wrote: Hugs is probably complaining because it identifies "x <- item" (which is not a simple expression) as the last element of do. That was my first guess, too, but it's not the case, switch to a monospaced font to see this. Juozas, you could on

Re: [Haskell-cafe] newbie question on Parsers from "Programming In Haskell"

2007-06-04 Thread C.M.Brown
Hi Juozas, > - > > type Parser a = String -> [(a, String)] > > return :: a -> Parser a > return v = \inp -> [(v, inp)] > > failure :: Parser a > failure = \inp -> [] > > > item :: Parser Char > item = \inp -> case inp of > [] -> [] > (x:xs) -

Re: [Haskell-cafe] newbie question on Parsers from "Programming In Haskell"

2007-06-04 Thread Dan Weston
David House wrote: Juozas, you could only use do-notation if your Parser type were declared an instance of the Haskell type-class Monad. Seeing as you haven't done this, you have to stick to the "de-sugared" version involving (>>=) and return: Is this true? I thought do (like all sugar) was des

Re: [Haskell-cafe] newbie question on Parsers from "Programming In Haskell"

2007-06-04 Thread Albert Y. C. Lai
Dan Weston wrote: Is this true? I thought do (like all sugar) was desugared before semantic analysis. So long as you have the right >>=, return, and fail in scope, I would have thought the desugaring is oblivious to their definition (and particularly ignorant of instancing of the Monad typecla

Re: [Haskell-cafe] newbie question on Parsers from "Programming In Haskell"

2007-06-05 Thread Ilya Tsindlekht
On Mon, Jun 04, 2007 at 05:42:35PM +0300, Juozas Gaigalas wrote: > Hello, > > I am a somewhat experienced programmer and a complete Haskell newbie, so I > hope this is the correct ML for my question. > > I have decided to learn Haskell and started with Graham Hutton's book. > Everything was goin