[Haskell-cafe] overloaded list literals?

Sebastian Fischer sebf at informatik.uni-kiel.de
Mon Sep 6 07:18:13 EDT 2010


On Sep 6, 2010, at 12:23 PM, Johannes Waldmann wrote:

> We have overloaded numerical literals (Num.fromInteger)
> and we can overload string literals (IsString.fromString),
> so how about using list syntax ( [], : )
> for anything list-like (e.g., Data.Sequence)?

As lists of some type A represent the free monoid over A, what if

     [x,y,z]

would be syntactic sugar for

     mconcat (map point (x:y:z:[]))

with

     class Pointed p where point :: a -> p a

Then list literals could be used for every pointed monoid.

Note that this only considers list literals. The (:) and []  
constructors would not be overloaded.

Sebastian


-- 
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)





More information about the Haskell-Cafe mailing list