Re: [Haskell-cafe] Sequencing Parsers: a Simple Example

1 Dec
2007
1 Dec
'07
12:02 p.m.
PRS: (>>=) :: Parser a -> Parser b -> Parser b p >>= f = \inp -> case p inp of [] -> [] [(v, out)] -> parse (f v) out
You probably want:
(>>=) :: Parser a -> (a -> Parser b) -> Parser b p >>= f = \inp -> case parse p inp of [] -> [] [(v,out)] -> parse (f v) out
Assuming that you're following Graham Hutton's book.
Note that this definition won't actually compile; you probably need a Monad instance and a newtype to get this to work properly (see http://www.cs.nott.ac.uk/~gmh/Parsing.lhs for a working version of the same code). PRS: That explains it then. [(v, out)] -> parse (f v) out caused a type mismatch. Cheers, Paul
6383
Age (days ago)
6383
Last active (days ago)
0 comments
1 participants
participants (1)
-
PR Stanley