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

Reply via email to