Le 20/03/2012 16:29, Tillmann Rendel a écrit :
Hi,

Thomas Schilling wrote:
I agree that the language standard should not prescribe the
implementation of a Text datatype.  It should instead require an
abstract data type (which may just be a newtype wrapper for [Char] in
some implementations) and a (minimal) set of operations on it.

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.

Is this still a problem if String would be replaced by an implementation-dependend newtype? Presumably, GHC would use a more efficient representation behind the newtype, so the following would be efficient in practice (or not?)

  newtype String
    = ...

  class IsString a where
    fromString :: String -> a

The standard could even prescribe that an instance for [Char] exists:

  explode :: String -> [Char]
  explode = ...

  instance IsString [Char] where
    fromString = explode

Tillmann

A recent message on Haskell-café made me think that if the standard mandates that any instance exists, it should mandates that an instance exists for CString and CWString (C's strings and wide strings) or, more generally, that an instance exists for any foreign string type defined in the FFIs implemented. That is to say, if you implement a FFI for .Net and you expose .Net's string type, you should implement conversions between that string type and Haskell's one.

Regards,
ARJANEN Loïc


_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to