Re: List syntax (was: Re: help from the community?)

2007-02-06 Thread Jeffrey Yasskin

On 2/5/07, Ulf Norell [EMAIL PROTECTED] wrote:


On Feb 3, 2007, at 6:35 AM, Douglas Philips wrote:

 Well, if we're going to bring personal points of view in, it highly
 pisses me off that in a construct such as:
 ( expr ,
   expr ,
   expr ,
   expr ,
   expr ,
 )
 I have to be vigilant to remove that trailing comma when it is in
 _no way_ ambiguous.

How about instead writing

( expr
, expr
, expr
, expr
, expr
)

The only extra work is when inserting an element at the beginning,
but you have the same problem in your example.


That style would be slightly improved by allowing a _leading_ comma:

[
, expr
, expr
, expr
, expr
, expr
]

In the trailing comma style, it looks like:

[
 expr ,
 expr ,
 expr ,
 expr ,
]

Both require a similar amount of extra space, but I've found the
second useful in python lists that change a lot, so I assume I'd find
similar use in Haskell lists. Of course, the layout proposal solves
this problem too, but it feels like a larger change.

Regarding tuples vs. lists, I care a lot less about tuples because
rearranging them usually requires a type change in lots of places, so
fixing a comma is the least of my worries.

Jeffrey Yasskin
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime


Re: map and fmap

2006-08-20 Thread Jeffrey Yasskin

On 8/20/06, John Hughes [EMAIL PROTECTED] wrote:


From: Jon Fairbairn [EMAIL PROTECTED]

 To
 reinforce what Aaron said, if a programme works now, it'll
 still work if map suddenly means fmap.

Well, this isn't quite true, is it? Here's an example:

class Foldable f where
  fold :: (a - a - a) - a - f a - a

instance Foldable [] where
  fold = foldr

example = fold (+) 0 (map (+1) (return 2))

example has the value 3 (of course), but if you replace map by fmap then the
code no longer compiles.


There's a proposal
http://hackage.haskell.org/trac/haskell-prime/wiki/Defaulting that
mentions extending defaulting to other typeclasses. That seems to fix
this particular problem, but above you mentioned that this was a
whole new can of worms. Could you elaborate or point me to a
discussion of the worms?

Thanks,
Jeffrey
___
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime