[Haskell-cafe] Badly designed Parsec combinators?

Juan Carlos Arevalo Baeza jcab.lists at JCABs-Rumblings.com
Sun Feb 12 09:22:46 EST 2006


Tomasz Zielonka wrote:
> On Sun, Feb 12, 2006 at 01:57:07PM +0100, Daniel Fischer wrote:
>   
>> Your above parser would be
>>
>> option Nothing (fmap Just p) -- or you might use liftM.
>>
>> Both are easy enough. If you think the naming is unfortunate, I wouldn't 
>> flatly contradict, but it's too late now, I believe.
>>     
>
> They are easy, but writing "option Nothing (liftM Just p)" for the nth
> time tends to be boring. I could write my own combinator, but all the
> good names are already taken. I too wish optional returned (Maybe a)
> and I wonder how many programs would be broken if it was changed now.
>   

   The only programs it would break are those that specify it at the end 
(they'd require an extra "return ()", right?

   This brings me to wonder also if it'd be possible for the compilers 
to add a little bit more smarts to the "do" notation syntax, so that 
it'll add the return () at the end if it's missing. Maybe too much to 
ask of the Haskell crowd :).

   In any case... I called them "optionalKeep" and "manyTillKeep". As 
in... "keep the result".

   Thanx! It's good to know it's not just me.

JCAB



More information about the Haskell-Cafe mailing list