Re: [Haskell-cafe] Comma in the front

2006-07-14 Thread Brian Hulley

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 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comma in the front

2006-07-13 Thread Jon Fairbairn
On 2006-07-13 at 02:29BST Neil Mitchell wrote:
 Hi,
 
  Are cool kids supposed to put the comma in front like this?
 Some cool kids do, some cool kids don't. Some do both, depending on their 
 mood.
 
 The advantage of a leading , is that now the comma's line up, and if
 you want to add an item on the end of a list
 
   [a
   ,b
   ,c
   ]
 
 It's just a one line change, whereas with the comma after, you'd have
 to change the previous line as well - which is more effort and gives
 more noise in the darcs copy.

This is one of my pet hates.  First, people find things
easier to read if they are in a form that they have
encountered lots of times before (in addition to
psycho-visual factors). I'd like to think that Haskell
programmers read a lot of literature (and since they should
have started reading this long before they learnt to
programme, and continue so to read, they're going to have
read more literature than code). So for me (and anyone else
moderately literate) a list written

[a,
 b,
 c
]

is easier to read and, (for folk who read from left to
right) gives emphasis to the important parts rather than the
punctuation. (Of course, a list with elements that short
would just be written [a, b, c] anyway.)

Now, you argue that it's more effort to add (or delete)
items from lists in this form, and maybe you are right (I do
it by dragging my mouse over stuff I want to remove, so
start with the comma and go down; it doesn't seem too
hard. If you want keystroke commands, you want something
that respects the syntax). The thing is, making
modifications that change the meaning /ought/ to be
effortful. If you can delete things without thinking about
it, you're probably going to delete something you shouldn't.

Then the argument from darcs -- well, historically diff is
line based, which was fine in the days of punch-cards, but
makes much less sense nowadays.  Ideally the diff darcs uses
should be syntax driven -- a nice project for someone; we
can save effort by only doing this for Haskell, and leave
programmers in other languages stuck with line-by-line
diffs.


 Jón

-- 
Jón Fairbairn  Jon.Fairbairn at cl.cam.ac.uk


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comma in the front

2006-07-13 Thread Henning Thielemann

On Thu, 13 Jul 2006, Jon Fairbairn wrote:

 On 2006-07-13 at 02:29BST Neil Mitchell wrote:
  Hi,
  
   Are cool kids supposed to put the comma in front like this?
  Some cool kids do, some cool kids don't. Some do both, depending on their 
  mood.
  
  The advantage of a leading , is that now the comma's line up, and if
  you want to add an item on the end of a list
  
[a
,b
,c
]
  
  It's just a one line change, whereas with the comma after, you'd have
  to change the previous line as well - which is more effort and gives
  more noise in the darcs copy.
 
 This is one of my pet hates.  First, people find things
 easier to read if they are in a form that they have
 encountered lots of times before (in addition to
 psycho-visual factors). I'd like to think that Haskell
 programmers read a lot of literature (and since they should
 have started reading this long before they learnt to
 programme, and continue so to read, they're going to have
 read more literature than code). So for me (and anyone else
 moderately literate) a list written
 
 [a,
  b,
  c
 ]

Optimal notation of lists, because of most easiest editing, is

a:
b:
c:
[]


=B-]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comma in the front

2006-07-13 Thread Jon Fairbairn
On 2006-07-13 at 11:15+0200 Henning Thielemann wrote:
 Optimal notation of lists, because of most easiest editing, is
 
 a:
 b:
 c:
 []

That made me smile. In Ponder I had used up : for types, and
lists could be

a::
b::
c:.

but when I suggested this at a Haskell meeting, Simon PJ
complained that it looks like hopscotch. I've never quite
understood that complaint!

 Jón


-- 
Jón Fairbairn  Jon.Fairbairn at cl.cam.ac.uk


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comma in the front

2006-07-13 Thread Mark T.B. Carroll
Jon Fairbairn [EMAIL PROTECTED] writes:

 a::
 b::
 c:.

 but when I suggested this at a Haskell meeting, Simon PJ
 complained that it looks like hopscotch. I've never quite
 understood that complaint!

http://blogs.salon.com/0002296/myimages/hopscotch.jpg and
http://www.northshield.org/officers/seneschal/moy/games/hopscotch.gif
suggest to me that the pattern of : and . going up in a row is a bit
like the squares along the linear 'course' (or list (-:) where sometimes
you get one and sometimes two.

-- Mark

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comma in the front

2006-07-13 Thread Jon Fairbairn
On 2006-07-13 at 09:35EDT [EMAIL PROTECTED] (Mark T.B. Carroll)  wrote:
 Jon Fairbairn [EMAIL PROTECTED] writes:
 
  a::
  b::
  c:.
 
  but when I suggested this at a Haskell meeting, Simon PJ
  complained that it looks like hopscotch. I've never quite
  understood that complaint!
 
 http://blogs.salon.com/0002296/myimages/hopscotch.jpg and
 http://www.northshield.org/officers/seneschal/moy/games/hopscotch.gif
 suggest to me that the pattern of : and . going up in a row is a bit
 like the squares along the linear 'course' (or list (-:) where sometimes
 you get one and sometimes two.

Well, perhaps (the pattern I associate with hopscotch is the
first, ie ·:·:·:·, which could never happen since :. is the
end of the list), but that still leaves open the question
What's bad about that? :-)

 Jón


-- 
Jón Fairbairn  Jon.Fairbairn at cl.cam.ac.uk


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comma in the front

2006-07-13 Thread Robert Dockins


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



I personally like this style.  It's a little hard to say why, but let  
me attempt.  I think it's related to layout.  Layout trained me to  
regard the end of lines as uninteresting, and the beginning as  
interesting.  Thus, I forget to put separators at the ends of lines  
(freedom from the tyranny of the semicolon!), but I always notice if  
a comma or semicolon is missing at the beginning of a line.  Its very  
obvious because they're all aligned vertically and, as I said,  
Haskell trains you to notice the leading edges of lines if you use  
layout.  It also makes it very visually obvious where the list/tuple/ 
do block ends when you line up the brackets with the separators.


IMO the patch/diff/darcs issue is a red herring.  It sounds like an  
after the fact justification to me.



Rob Dockins

Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
  -- TMBG



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Comma in the front

2006-07-13 Thread Tim Docker

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

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Comma in the front

2006-07-13 Thread Tomasz Zielonka
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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe