
Am Sonntag, 15. März 2009 23:50 schrieb Ben Franksen:
This is mostly due to the class method 'empty'.
First of all, this is a bad name, /especially/ in the context of parsers, where 'empty' intuitively means 'recognize the empty sequence of tokens' which is definitely /not/ what Alternative's 'empty' means. (Indeed, this is normally be the meaning of 'pure' from class Applicative.)
The 'empty' from Alternative rather means 'fail'. Yeah, I know that this name is already taken by class Monad. Many names would be better than 'empty', for instance 'none', or just 'failed'. (I'll stick with 'none' in what follows.)
The parser fails so “fail” might be a good name. However, when using an applicative style for writing parsers (in contrast to the “imperative” do notation), you almost write a grammar of your language. And “empty” just denotes the empty language. So the name might be not as bad as it first looks like. Best wishes, Wolfgang