[Haskell-cafe] Badly designed Parsec combinators?

Udo Stenzel u.stenzel at web.de
Thu Feb 16 15:12:26 EST 2006


Juan Carlos Arevalo Baeza wrote:
> Udo Stenzel wrote:
> >Don't you think this will interfere somehow with type inference?
> 
>   With type inference? No, why? I mean... specifying the type of a 
> function [...]

Okay, so want an implicit (return ()) only if the type of the do-block
has been explicitly specified as (m ()) for a monad m.  I've become used
to type inference and assumed you wanted to tack on the (return ()) if
the corresponding type was only inferred.  The former is less
destructive, of course.  I still dislike it, being a special rule with
very limited use.


> >yourParser :: Parser String
> >yourParser = liftM2 (++) (string "Hello")
> >                         (option "" (string ", world!")
> 
>   Personally, that style is way too functional (and a bit lisp-ish) for 
> me.

Uhm, well, of course you're entitled to an opinion, but I know where to
find the children of Algol when I need them...

> >ourParser :: Parser String
> >ourParser = string "Hello" *> optional (string ", world!")
> 
>   So you do drop returned values now and then? But with that function 
> you lose out on the do-notation convenience.

Why, yes, I do, but I like being explicit about it.  (And I'm not sure
that (*>) is explicit enough.)  And I must confess, I don't find
do-notation all that convenient.  If it weren't for fail being called if
a pattern match fails, I'd probably never use it at all.


> >I'm more reminded of Perl...
> 
>   I don't know perl :)

You're a very lucky man.  (No, seriously, Perl is quite the opposite
of Haskell in nearly every aspect.)


Udo.
-- 
fork(2) 
    New processes are created by other processes, just like new humans.
    New humans are created by other humans, of course, not by processes.
	-- Unix System Administration Handbook
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060216/0d6a840e/attachment.bin


More information about the Haskell-Cafe mailing list