[Haskell-beginners] Parser as an instance of the monad class

Paul Higham polygame at mac.com
Fri Jan 14 07:06:36 CET 2011


I Just looked at it after your suggestion, Maybe I should have looked  
at it before, because it's way better than the Nothing I was using!

Thanx for the tip,

::paul

On Jan 12, 2011, at 12:01 AM, Iustin Pop wrote:

> On Tue, Jan 11, 2011 at 11:39:48PM -0800, Paul Higham wrote:
>> There are a number of ugly things that you can do at this point that
>> are just plain wrong, so I thought that the right thing to do would
>> be to get the Parser type to be manifested as an instance of the
>> Monad class.  Ok, now what?  Since Parser is only a type synonym it
>> cannot be used directly in the following way:
>>
>>   instance Monad Parser where
>>      return v = . . .
>>      p >>= f  = . . .
>>
>> but since Parser is not an algebraic type as it is defined that
>> won't work either.  So how do you do it?  help .
>
> Have you looked at the book's website? He provides the entire
> Parsing.lhs library, and you can see there an example of how to do it.
>
> regards,
> iustin




More information about the Beginners mailing list