Two Proposals

Jan-Willem Maessen jmaessen at alum.mit.edu
Mon Oct 10 04:03:29 CEST 2011


2011/10/5 Simon Peyton-Jones <simonpj at microsoft.com>:
> |  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
>        [a,b,c]
> 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.

No, you should not.  Most of the types of interest (Sets, Maps,
arrays) are not monads.  Conflating list comprehensions with monads is
a huge mistake, and this would repeat it.

-Jan



More information about the Glasgow-haskell-users mailing list