kfl / simpleparse

Simple to understand parser combinator library
MIT License
2 stars 2 forks source link

Add type signatures and other small stylistic improvements. #3

Closed athas closed 10 years ago

athas commented 10 years ago

Here are my first proposed improvements. The insertion of type signatures should not be controversial. The use of liftM is perhaps more so, but I think we should try to demonstrate good Haskell usage - and in class, we can show the non-sugared version. The many/many1 recursive relationship is a bit funky, but I think it demonstrates the point that parser combinators are usually extended, rather than restricted, and saves on code duplication.

One thing I have not done is made Parser an instance of Alternative. We should seriously consider this, however, if only because it may "soon" be an error for something to be just an instance of MonadPlus.

kfl commented 10 years ago

Actually I don't like neither of our parseEof definitions. But I don't really see yours are any cleaner nor understandable than mine.