[Haskell-beginners] Monads and infinite types

Chaddaï Fouché chaddai.fouche at gmail.com
Sun Aug 31 02:45:24 EDT 2008


2008/8/31 Tillmann Rendel <rendel at daimi.au.dk>:
>> instance Monad NMEAParser where
>>  return a  = NMEAParser(\s -> (SingleVal a,s))
>>  NMEAParser k >>= f = NMEAParser(\s0 -> let (r1, s1) = k s0
>>                                             k2 = f r1
>>                                             (r2, s2) = k2 s1 in
>>                                         (r1,s2))

"f r1" evaluates to a parser, you forgot to pattern match, k2 isn't a
function, it's a parser.

-- 
Jedaï


More information about the Beginners mailing list