Re: Are pattern guards obsolete?
Donald Bruce Stewart [EMAIL PROTECTED] wrote: The joy of pattern guards reveals once you have more conditions. I wrote: Of course, this is not really the joy of pattern guards. It is the joy of monads, with perhaps a few character strokes saved by a confusing overloading of (-). Philippa Cowderoy wrote: I don't find it any more confusing than the overloading of -. You mean that it is used both for lambda abstractions and for functional dependencies? True, but those are so different that there is no confusion. Note that it's not (-) - it's not an operator. Right, it is syntactic sugar for a monad. But this syntax is already used in two places: do notation and list comprehensions. The semantics are exactly the same in both existing uses. The semantics of the proposed new use in pattern guards is quite different, as was discussed in the previous thread. Yet close enough to be confused. There seems to be a consensus that pattern guards are here to stay. So I am proposing to mitigate the damage somewhat by using a different but similar symbol . That matches the different but similar semantics. I mentioned (-) as one possibility. Regards, Yitz ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
On Wed, 13 Dec 2006, Yitzchak Gale wrote: Yitzchak Gale wrote: Of course, this is not really the joy of pattern guards. It is the joy of monads, with perhaps a few character strokes saved by a confusing overloading of (-). Philippa Cowderoy wrote: I don't find it any more confusing than the overloading of -. You mean that it is used both for lambda abstractions and for functional dependencies? True, but those are so different that there is no confusion. You missed out case statements. -- [EMAIL PROTECTED] My religion says so explains your beliefs. But it doesn't explain why I should hold them as well, let alone be restricted by them. ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
On Wed, 13 Dec 2006, Yitzchak Gale wrote: Philippa Cowderoy wrote: I don't find it any more confusing than the overloading of -. I wrote: You mean that it is used both for lambda abstractions and for functional dependencies? True, but those are so different that there is no confusion. Oh, and case. Also quite different. This is what I get for replying straight away! Anyway, existing problems are not an excuse to repeat the mistake and make matters even worse. I think my point is that I'm not aware of many people who actually think this is a problem or get confused. -- [EMAIL PROTECTED] There is no magic bullet. There are, however, plenty of bullets that magically home in on feet when not used in exactly the right circumstances. ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
Philippa Cowderoy wrote: This is what I get for replying straight away! Oh, no, I'm happy that you responded quickly. I think my point is that I'm not aware of many people who actually think this is a problem or get confused. Well, I don't mean that this is something that experienced Haskell programmers will stop and scratch their heads over. But the more of these kinds of inconsistencies you have, the worse it is for a programming language. The effect is cumulative. When there are too many of them, they make the language feel heavy, complex, and inelegant. They increase the number of careless errors. They put off beginners. Regards, Yitz ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
Hi, I am not clear why you think the current notation is confusing... Could you give a concrete example? I am thinking of something along the lines: based on how - works in list comprehensions and the do notation, I would expect that pattern guards do XXX but instead, they confusingly do YYY. I think that this will help us keep the discussion concrete. -Iavor On 12/13/06, Yitzchak Gale [EMAIL PROTECTED] wrote: Philippa Cowderoy wrote: This is what I get for replying straight away! Oh, no, I'm happy that you responded quickly. I think my point is that I'm not aware of many people who actually think this is a problem or get confused. Well, I don't mean that this is something that experienced Haskell programmers will stop and scratch their heads over. But the more of these kinds of inconsistencies you have, the worse it is for a programming language. The effect is cumulative. When there are too many of them, they make the language feel heavy, complex, and inelegant. They increase the number of careless errors. They put off beginners. Regards, Yitz ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
Iavor Diatchki wrote: I am not clear why you think the current notation is confusing... Could you give a concrete example? I am thinking of something along the lines: based on how - works in list comprehensions and the do notation, I would expect that pattern guards do XXX but instead, they confusingly do YYY. I think that this will help us keep the discussion concrete. Pattern guards basically are a special-case syntactic sugar for (instance MonadPlus Maybe). The guard foo m x | empty m = bar | Just r - lookup x m, r == 'a' = foobar directly translates to foo m x = fromMaybe $ (do { guard (empty m); return bar;}) `mplus` (do {Just r - return (lookup m x); guard (r == 'a'); return foobar;}) The point is that the pattern guard notation Just r - lookup m x does *not* translate to itself but to Just r - return (lookup m x) in the monad. The - in the pattern guard is a simple let binding. There is no monadic action on the right hand side of - in the pattern guard. Here, things get even more confused because (lookup m x) is itself a Maybe type, so the best translation into (MonadPlus Maybe) actually would be r - lookup m x Regards, apfelmus ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
I am not clear why you think the current notation is confusing... Could you give a concrete example? I am thinking of something along the lines: based on how - works in list comprehensions and the do notation, I would expect that pattern guards do XXX but instead, they confusingly do YYY. I think that this will help us keep the discussion concrete. consider the following examples: -- do-notation: explicit return; explicit guard; monadic result d _ = do { Just b - return (Just True); guard b; return 42 } -- list comprehension: explicit return; implicit guard; monadic (list) result lc _ = [ 42 | Just b - return (Just True), b ] -- pattern guard: implicit return; implicit guard; non-monadic result pg _ | Just b - Just True, b = 42 in spite of their similarity, all of these constructs handle some of the monadic aspects differently. the translations of pattern guards not only embed statements in guard, they also embed the right hand sides of generators in return. translations of list comprehensions only lift statements. translation of do-notation lifts neither statements nor generators. does this clarify things? Claus ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
Hi in spite of their similarity, all of these constructs handle some of the monadic aspects differently. the translations of pattern guards not only embed statements in guard, they also embed the right hand sides of generators in return. translations of list comprehensions only lift statements. translation of do-notation lifts neither statements nor generators. does this clarify things? No. Pattern guards are obvious, they could only work in one particular way, and they do work that way. They make common things easier, and increase abstraction. If your only argument against them requires category theory, then I'd say that's a pretty solid reason for them going in. The argument that people seem to be making is that they are confusing, I completely disagree. f value | Just match - lookup value list = g match Without thinking too hard, I am curious how anyone could get the meaning of this wrong if they understand the rest of Haskell. Can you show a concrete example, where you think a user would get confused? Thanks Neil ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Are pattern guards obsolete?
Yitzchak Gale writes: Philippa Cowderoy wrote: I don't find it any more confusing than the overloading of -. I wrote: You mean that it is used both for lambda abstractions and for functional dependencies? True, but those are so different that there is no confusion. Oh, and case. Also quite different. Also type and kind signatures. The use in case and lambda abstractions strike me as analogous. They both have a pattern to the left and an expression to the right. -- David Menendez [EMAIL PROTECTED] | In this house, we obey the laws http://www.eyrie.org/~zednenem |of thermodynamics! ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime