
On Jul 12, 2006, at 9:18 PM, Joel Reymont wrote:
Are cool kids supposed to put the comma in front like this?
, foo , bar , baz
Is this for historical or other reasons because Emacs formats Haskell code well enough regardless.
Thanks, Joel
These layouts feel a bit artificial to me. I am quite partial to python's list syntax - a trailing comma is optional. meaning you can write [ a, b, c, ] I'm surprised this approach isn't more widespread - Are there reasons why haskell syntax could not/should not be defined this way? Tim

Hi
[ a, b, c, ]
I'm surprised this approach isn't more widespread - Are there reasons why haskell syntax could not/should not be defined this way?
I believe GHC allows multiple commas after each other in some places, for example module export lists. Unfortunately the only reason I know this is because it broke code for Hugs. I don't think its technically infeasible to do this, it was just not decided upon at the time. There might be issues with tuples though, for example (1,2,) would be the (,) tuple and not the (,,) tuple, which is a bit weird. Thanks Neil

On Fri, Jul 14, 2006 at 01:01:23AM +0100, Neil Mitchell wrote:
There might be issues with tuples though, for example (1,2,) would be the (,) tuple and not the (,,) tuple, which is a bit weird.
Besides, it might be a bit more natural if (1,2,) was a shorthand for (\x -> (1,2,x)) Best regards Tomasz

Hello Tomasz, Friday, July 14, 2006, 9:31:32 AM, you wrote:
There might be issues with tuples though, for example (1,2,) would be the (,) tuple and not the (,,) tuple, which is a bit weird.
Besides, it might be a bit more natural if (1,2,) was a shorthand for (\x ->> (1,2,x))
in haskell-prime list there was a proposal to use '?' for such things: (1,2,?) only problem is what it's hard to define exactly where the lambda should arise: (1,2,\x->x) (\x -> (1,2,x)) or even at some more outer level. aside of this, it would be very handy addition to various existing partial application styles: f a `f` a a `f` (*2) (2*) (*) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Fri, 14 Jul 2006, Bulat Ziganshin wrote:
Hello Tomasz,
Friday, July 14, 2006, 9:31:32 AM, you wrote:
There might be issues with tuples though, for example (1,2,) would be the (,) tuple and not the (,,) tuple, which is a bit weird.
Besides, it might be a bit more natural if (1,2,) was a shorthand for (\x ->> (1,2,x))
in haskell-prime list there was a proposal to use '?' for such things:
(1,2,?)
only problem is what it's hard to define exactly where the lambda should arise:
(1,2,\x->x) (\x -> (1,2,x))
Yes that's a really evil problem that I already encountered in mathematics. Some mathematicians like to write f(�) or even f(�-k) which exhibits exactly the ambiguity you mention. Such placeholders are a really bad idea.

Henning Thielemann schrieb:
in haskell-prime list there was a proposal to use '?' for such things:
(1,2,?)
only problem is what it's hard to define exactly where the lambda should arise:
the placeholder '?' becomes part of a new implicit identifier (that exceeds Haskell's identifier syntax). If we have: (,,) :: a -> b -> c -> (a, b, c) we get a bunch of new identifiers: (?,,) :: b -> c -> a -> (a, b, c) (,?,) :: a -> c -> b -> (a, b, c) (,,?) :: a -> b -> c -> (a, b, c) And maybe also: (?,?,) :: c -> a -> b -> (a, b, c) and so on. For infix ops this looks natural to me.
(1,2,\x->x)
I see no reason for this interpretation.
(\x -> (1,2,x))
That should exactly be the implicit definition of my above implicit identifiers.
Yes that's a really evil problem that I already encountered in mathematics. Some mathematicians like to write f(·) or even f(·-k) which exhibits exactly the ambiguity you mention. Such placeholders are a really bad idea.
"f(?)" should not make sense in Haskell, since the parens do not belong to the identifier "f". (It's also not necessary: \ x -> f(x) = f) Cheers Christian

On Fri, 14 Jul 2006, Christian Maeder wrote:
Henning Thielemann schrieb:
in haskell-prime list there was a proposal to use '?' for such things:
(1,2,?)
only problem is what it's hard to define exactly where the lambda should arise:
the placeholder '?' becomes part of a new implicit identifier (that exceeds Haskell's identifier syntax). If we have:
(,,) :: a -> b -> c -> (a, b, c)
we get a bunch of new identifiers:
(?,,) :: b -> c -> a -> (a, b, c) (,?,) :: a -> c -> b -> (a, b, c) (,,?) :: a -> b -> c -> (a, b, c)
And maybe also: (?,?,) :: c -> a -> b -> (a, b, c)
and so on. For infix ops this looks natural to me.
I see. It would require that ? belongs to tuples exclusively and that it will never be used elsewhere, say for lists like in [1,2,?]. Because then the expression [(1,?)] becomes ambigous. Like with every kind of syntactic sugar, I fear that the next thing that people request, are expressions like (1,2,3+?) for \x -> (1,2,3+x)
Yes that's a really evil problem that I already encountered in mathematics. Some mathematicians like to write f(·) or even f(·-k) which exhibits exactly the ambiguity you mention. Such placeholders are a really bad idea.
"f(?)" should not make sense in Haskell, since the parens do not belong to the identifier "f". (It's also not necessary: \ x -> f(x) = f)
Necessary or not, applied mathematicians don't care about redundancy. :-) I have seen $f(\cdot)$ instead of $f$ really often, as well as $f(\cdot-k)$ for \x -> f(x-k).

Henning Thielemann schrieb:
I have seen $f(\cdot)$ instead of $f$ really often, as well as $f(\cdot-k)$ for \x -> f(x-k).
yes, but for first order functions only. Then parens can be seen as part of the identifier (as I showed for tuples before). Christian

Tim Docker wrote:
These layouts feel a bit artificial to me. I am quite partial to python's list syntax - a trailing comma is optional. meaning you can write
[ a, b, c, ]
I'm surprised this approach isn't more widespread - Are there reasons why haskell syntax could not/should not be defined this way?
I think this would be confusing because it looks like a syntax error - the last element is missing. The advantage of just having comma as a separator is that it allows syntax errors to be detected, whereas making it optional would mean one less error is detected at compile time. I'll take this opportunity to re-present my hyper-cool syntax proposal for lists ;-) : #[ a b c No need for commas or a closing ] because we could just use layout! Regards, Brian. -- Logic empowers us and Love gives us purpose. Yet still phantoms restless for eras long past, congealed in the present in unthought forms, strive mightily unseen to destroy us. http://www.metamilk.com
participants (7)
-
Brian Hulley
-
Bulat Ziganshin
-
Christian Maeder
-
Henning Thielemann
-
Neil Mitchell
-
Tim Docker
-
Tomasz Zielonka