Don't forget that with -XOverloadedStrings we already have a IsString class. (That's not a Haskell Prime extension though.)
class IsString a where fromString :: String -> a Simon | -----Original Message----- | From: haskell-prime-boun...@haskell.org [mailto:haskell-prime- | boun...@haskell.org] On Behalf Of Johan Tibell | Sent: 19 March 2012 15:54 | To: Thomas Schilling | Cc: haskell-prime@haskell.org | Subject: Re: String != [Char] | | On Mon, Mar 19, 2012 at 8:45 AM, Thomas Schilling | <nomin...@googlemail.com> wrote: | > Regarding the type class for converting to and from that type, there | > is a perhaps more complicated question: The current fromString method | > uses String as the source type which causes unnecessary overhead. This | > is unfortunate since GHC's built-in mechanism actually uses | > unpackCString[Utf8]# which constructs the inefficient String | > representation from a compact memory representation. I think it would | > be best if the new fromString/fromText class allowed an efficient | > mechanism like that. unpackCString# has type Addr# -> [Char] which is | > obviously GHC-specific. | | I've been thinking about this question as well. How about | | class IsString s where | unpackCString :: Ptr Word8 -> CSize -> s | | It's morally equivalent of unpackCString#, but uses standard Haskell types. | | -- Johan | | _______________________________________________ | Haskell-prime mailing list | Haskell-prime@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-prime _______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime