Re: pattern guards and guarded patterns

1997-04-30 Thread Alex Ferguson
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

Re: A new view of guards

1997-04-30 Thread Hans Aberg
At 09:15 97-04-28, Simon L Peyton Jones wrote: >A proposal >~~~ >The proposal I want to make is simple: > >Instead of being a boolean expression, >a guard is a list of qualifiers, >exactly as in a list comprehension. > >That is, the only syntax change is to

Re: A new view of guards

1997-04-30 Thread Alex Ferguson
Oh, I forgot to say, concerning the Alternative Syntax (strict where's) Simon mentions; I think this is not supportable, particularly for the program-breaking reason SPJ mentions. (And especially because lots of the borken programs would be mine, and I shudder at the thought of adding ~'s all ov

Re: A new view of guards

1997-04-30 Thread Frank Christoph
> Is this a storm in a teacup? Much huff and puff for a seldom-occurring > situation? No! It happens to me ALL THE TIME. The Glasgow Haskell Compiler > is absolutely littered with definitions like clunky. I experience the same problem all the time as well and it drives me crazy. I think this

pattern guards and guarded patterns

1997-04-30 Thread Tommy Thorn
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 | ..

Re: pattern guards and guarded patterns

1997-04-30 Thread Pablo E. Martinez Lopez
>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 >

Re: pattern guards and guarded patterns

1997-04-30 Thread Philip Wadler
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

Re: A new view of guards

1997-04-30 Thread Libor Skarvada
Tony Davie writes: > >I'm quite comfortable with the idea. Guards are part of the lhs of an > >equation, and that is where binding takes place. > > > >The <- syntax worries me a bit, because in the comprehension use it has a > >different type, but the let syntax is available, and one can write > >

Re: A new view of guards

1997-04-30 Thread Andrew Moran
Brian Boutel writes: > The <- syntax worries me a bit, because in the comprehension use it has a > different type, but the let syntax is available, and one can write "let p = > e" "for p <- e". I think that, to reduce possible confusion, I would use, > and teach, the let form. Given that, I don't

Re: A new view of guards

1997-04-30 Thread Tony Davie
Greg said: >To parade my ignorance... Something that's always puzzled me about Haskell >is when to do something on the left and when on the right of a function >definition. For example, there must be at least 4 ways of writing the factorial >function: pattern match; guard; if ... then ... else ..

Re: A new view of guards

1997-04-30 Thread Brian Boutel
I'm quite comfortable with the idea. Guards are part of the lhs of an equation, and that is where binding takes place. The <- syntax worries me a bit, because in the comprehension use it has a different type, but the let syntax is available, and one can write "let p = e" "for p <- e". I think

Re: A new view of guards

1997-04-30 Thread Simon Marlow
John Lauchbury writes: > Simon's syntax also provides a viable alternative to @ patterns > f x @ (Just 3) y = e > f x y | Just 3 <- x = e > though it is slightly less convenient in certain contrived examples (but > very much less ad hoc). Reversing this idea, we have another syntax for S

Re: A new view of guards

1997-04-30 Thread Stefan Kahrs
I very much like Simon's proposal. It's useful, clean, fits neatly into the syntax, and does not cause any difficult implementation problems. In other words, it fits all the requirements of good language design. Tony Davie wrote: > Yes. I really like the fact that at last guards in comprehension

Re: A new view of guards

1997-04-30 Thread Greg Michaelson
To parade my ignorance... Something that's always puzzled me about Haskell is when to do something on the left and when on the right of a function definition. For example, there must be at least 4 ways of writing the factorial function: pattern match; guard; if ... then ... else ...; list comprehe

Re: A new view of guards

1997-04-30 Thread D. tweed
DISCLAIMER: I've never written a `large' application in Haskell and perhaps don't appreciate the problems. I _do_ use Haskell for personal progams because its so much quicker and easier to get right. (Work is mandated in C++) I like Simon Peyton Jones basic extension of guards. However, I'm a bit

Re: A new view of guards

1997-04-30 Thread Tony Davie
>I'm quite comfortable with the idea. Guards are part of the lhs of an >equation, and that is where binding takes place. > >The <- syntax worries me a bit, because in the comprehension use it has a >different type, but the let syntax is available, and one can write >"let p = e" "for p <- e". I th

pattern guards and guarded patterns

1997-04-30 Thread Chris Dornan
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

Re: pattern guards and guarded patterns

1997-04-30 Thread Simon L Peyton Jones
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