I think Herbert's monadic version of "clunky" is really satisfactory :
>clunky env var1 var2 = fromJust (do val1 <- lookup var1 env
> val2 <- lookup var2 env
> return (var1 + var2)
> ++
>
Errata:
in my previous mail, the text "a la Hoare" should be replaced by "a la
Dijkstra".
Fidel.
> 3. I think it's quite important to use "<-" rather than "=".
> a) it means that the syntax is precisely that of list comprehensions
> b) there's an "=" in the definition already, as Andy points out:
> simplify (Plus e e') | let (Val 0) = s = s'
>
A couple of minor counter-quibbles:-
Pablo E. Martinez Lopez suggests:
> You can define your own "sequential if" a la Hoare:
>
>data GuardedExp a = Bool :? a
>
>seqif :: [GuardedExp a] -> a
>seqif [True:?a] = a
>seqif ((b:?a):x:xs) = if b then a else seqif (x:xs
I can see the arguments for the pattern guard extension and the syntax
seem reasonable.
I also agree with Chris on the shortcomings of if-then-else. (I have
disliked it in any language where I've seen it, and it "feels"
un-Haskell-like to me.) On the other hand, the suggested
case
| ..
>I have longstanding dislike of Haskell's expression conditional:
> The problem comes when several conditions are
> present, provoking a rightward march. In this case I use
>
> if test1 then
> part1
> else if test2 then
>
Tommy Thorn writes:
> My only worry is that Haskell (if not already) is turning into the C++
> of functional languages, ie. feature upon feature. Haskell is already
> quite a mouthfull to learn.
This worries me too. Not least is the problem that <- is not a
particularly natural syntax for this
In `A new view of guards', Simon cited
> [2] W Burton, E Meijer, P Sansom, S Thompson, P Wadler, "A (sic) extension
> to Haskell 1.3 for views", sent to the Haskell mailing list
> 23 Oct 1996
Was that posted on this Haskell mailing list? Does anyone know where I could
get a copy
Thanks for feedback about pattern guards. Here are some quick responses.
1. Several people have suggested something along the lines of being
able to backtrack half way through a pattern guard. I considered this
but (a) I couldn't see a nice syntax for it and
(b) it's against the spirit of