Two Proposals

Simon Peyton-Jones simonpj at
Wed Oct 5 12:58:17 CEST 2011

|  In the spirit of "don't let the perfect be the enemy of the good"
|  though, I'm solidly in favor of the original proposal as it is. 

This is my thought too.  George is proposing to extend Haskell's existing mechanism for numeric literals (namely, replace 4 by (fromInteger (4::Integer))), so that it works for lists, just as Lennart did for Strings.  One could do more, as Yitz has suggested, but that would be an altogether bigger deal, involving Template Haskell and quite a bit of new design; and if done should apply uniformly to numeric and string literals too. 

So personally I favour George's general approach as a first step.  But here is one thought.  In the spirit of monad comprehensions, should we not treat
as short for
	return a `mappend` return b `mappend` return c
so that [a,b,c] syntax is, like [ e | x <- xs ] syntax, just short for monadic goop.  Then we would not need a new class at all, which would be nice.

That isn't quite what Roman was suggesting (he wanted to supply the 'cons' and 'nil') but it's closer, less "head-biased", and it seems to fit the spirit of monad comprehensions.

I'm not sure if this plan would support [("fred",45), ("bill",22)] :: Map String Int.  Probably not.   Maybe that's a shortcoming... but such Maps are a rather surprising use of list literals.  


More information about the Glasgow-haskell-users mailing list