[Haskell-cafe] Call for discussion: OverloadedLists extension

Sjoerd Visscher sjoerd at w3future.com
Tue Sep 25 19:57:32 CEST 2012


So, in order not to have to rely on rewrite rules, would it be a good idea to add unpackCString to the IsString class?

import GHC.Base (unpackCString#, Addr#)

class IsString a where
    fromString :: String -> a
    unpackCString :: Addr# -> a
    unpackCString addr = fromString (unpackCString# addr)

For lists something similar could probably be done.

Sjoerd

On Sep 25, 2012, at 10:01 AM, Simon Peyton-Jones <simonpj at microsoft.com> wrote:

> | Here at the University of Tübingen, I am co-supervising (together with
> | Jeroen Weijers) a student project implementing the OverloadedLists
> | extension for GHC. Achim Krause is the student who is working on the
> | project. We took into consideration earlier discussions on this topic
> | [1,2] before embarking on the project.
> | 
> | Achim has worked on two approaches.
> 
> Your second approach is this:
> 
> | [x,y,z] 
> | 
> | as
> | 
> | singleton x `mappend` singleton y `mappend` singleton z ;
> 
> This approach is not good for long literal lists, because you get tons of executable code where the user thought he was just defining a data  structure.  And long literal lists are an important use-case.
> 
> One other possibility is to use a variant of what GHC does for literal strings. Currently
> 	"foo"
> turns into	
> 	unpackCString "foo"#
> where "foo"# is a statically allocate C string, and the "unpackCString" unpacks it lazily.
> 
> Maybe we could make a literal [a,b.c] turn into
> 	unpack [a,b,c]#
> where 
> 	[a,b,c]#
> is a statically-allocated vector?  See http://hackage.haskell.org/trac/ghc/ticket/5218, which is stalled awaiting brain cycles from someone.
> 
> I'm maxed out at the moment.  I'd be very happy if you guys were able to make progress; I'm happy to advise.  Open a ticket, start a wiki page, etc!
> 
> Simon
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe




More information about the Haskell-Cafe mailing list