RE: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Mitchell, Neil
Generalised? Heck, I don't use list comprehension at all! :-P Perhaps you should! :-) You definitely should! Take a look at the Uniplate paper for some wonderful concise uses of list comprehensions for abstract syntax tree traversals. If you use a language like F# they become even more

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Duncan Coutts
On Sun, 2008-11-09 at 19:18 +, Andrew Coppin wrote: Derek Elkins wrote: As far as I can tell, no one actually uses parallel list comprehensions. With any luck, the same will be true for generalized list comprehensions. Generalised? Heck, I don't use list comprehension at all!

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Andrew Coppin
Duncan Coutts wrote: On Sun, 2008-11-09 at 19:18 +, Andrew Coppin wrote: Generalised? Heck, I don't use list comprehension at all! :-P Perhaps you should! :-) When I first started with Haskell I kind of had the idea that list comprehensions were just for beginners and that

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Andrew Coppin
Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Luke Palmer
Because expressions are treated as guards in list comprehensions. I.e.: [ foo | x - a, b, y - c, d ] Is interpreted as: do x - a guard b y - c guard d return foo Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Jonathan Cast
On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? Is there any specific reason to dis-allow it? The grammar here

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Jonathan Cast
On Mon, 2008-11-10 at 18:19 +, Andrew Coppin wrote: Duncan Coutts wrote: On Sun, 2008-11-09 at 19:18 +, Andrew Coppin wrote: Generalised? Heck, I don't use list comprehension at all! :-P Perhaps you should! :-) When I first started with Haskell I kind of had the

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Andrew Coppin
Jonathan Cast wrote: On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? Is there any specific reason to

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Duncan Coutts
On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? It is due to the rules for the translation of list comprehensions:

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Duncan Coutts
On Mon, 2008-11-10 at 18:19 +, Andrew Coppin wrote: I don't actually use *lists* all that much - or at least not list transformations. And if I'm going to do something complicated, I'll usually write it as a do-expression rather than a comprehension. Just a random example out of

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Jonathan Cast
On Mon, 2008-11-10 at 18:48 +, Andrew Coppin wrote: Jonathan Cast wrote: On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any

Re: [Haskell-cafe] generalized list comprehensions

2008-11-10 Thread Derek Elkins
On Mon, 2008-11-10 at 18:50 +, Duncan Coutts wrote: [...] If you meant, why is it allowed rather than banned then I guess the answer is because it is orthogonal. The rules naturally handle that case and there was no particular reason to ban it, even if it is somewhat unusual. Unusual?

Re: [Haskell-cafe] generalized list comprehensions

2008-11-09 Thread Max Bolingbroke
2008/11/9 Johannes Waldmann [EMAIL PROTECTED]: NB: Wasn't there a time (before do) when list notation (brackets) would work in any monad? And map was a method in Functor, and we had class Functor m = Monad m, etc. Well well well times have changed. Sure, I believe the feature was called monad

Re: [Haskell-cafe] generalized list comprehensions

2008-11-09 Thread Johannes Waldmann
like [(x, y) | x - xs | y - ys], and it's not clear how to define zip for a monad - but perhaps there is some extension of a monad where it makes sense? Well, I question that the above notation makes sense (for lists). It is trying to be too clever. standard list comprehensions at least are

Re: [Haskell-cafe] generalized list comprehensions

2008-11-09 Thread Andrew Coppin
Derek Elkins wrote: As far as I can tell, no one actually uses parallel list comprehensions. With any luck, the same will be true for generalized list comprehensions. Generalised? Heck, I don't use list comprehension at all! :-P ___ Haskell-Cafe

Re: [Haskell-cafe] generalized list comprehensions

2008-11-09 Thread Derek Elkins
On Sun, 2008-11-09 at 10:15 +, Max Bolingbroke wrote: 2008/11/9 Johannes Waldmann [EMAIL PROTECTED]: NB: Wasn't there a time (before do) when list notation (brackets) would work in any monad? And map was a method in Functor, and we had class Functor m = Monad m, etc. Well well well

Re: [Haskell-cafe] generalized list comprehensions

2008-11-09 Thread Yitzchak Gale
Derek Elkins wrote: As far as I can tell, no one actually uses parallel list comprehensions. With any luck, the same will be true for generalized list comprehensions. I second this. -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] generalized list comprehensions

2008-11-08 Thread Johannes Waldmann
Looking at this funny new feature http://haskell.org/ghc/docs/6.10.1/html/users_guide/syntax-extns.html#generalised-list-comprehensions I have just one question - why doesn't this work with the do-notation? I avoid list comprehensions because I feel that return belongs at the end, not in front.

Re: [Haskell-cafe] generalized list comprehensions

2008-11-08 Thread Max Bolingbroke
2008/11/8 Johannes Waldmann [EMAIL PROTECTED]: Looking at this funny new feature http://haskell.org/ghc/docs/6.10.1/html/users_guide/syntax-extns.html#generalised-list-comprehensions I have just one question - why doesn't this work with the do-notation? I avoid list comprehensions because I

Re: [Haskell-cafe] generalized list comprehensions

2008-11-08 Thread Johannes Waldmann
I don't think we considered the possibility you might use do notation for the list monad, as it's not an idiom that seems to occur often. depends where you look, I guess. (Such questions could in principle be answered automatically by browsing the code on hackage?) As I said, I am avoiding