String != [Char]
haskell at benmachine.co.uk
Fri Mar 23 17:03:51 CET 2012
On Fri, Mar 23, 2012 at 1:24 PM, Greg Weber <greg at gregweber.info> wrote:
> I would really just like for someone to show me how to create a wiki
> proposal page :)
> This proposal doesn't have to break any codebases.
> One possibility is to add the Text type to the standard while keeping
> String and marking it as deprecated.
I'm in favour of this. In fact, I'm not sure if I would even deprecate
String. I think just adding Text or something Text-like to the
standard would be a good step towards encouraging libraries to use it
as their first choice. It might, however, be wise to first adopt GHC's
OverloadedStrings proposal so that the syntax for using string
alternatives is more convenient.
I'm inclined to start slow and small: OverloadedStrings is already in
use, and makes sense with overloaded numeric literals that we already
have, so I think it's reasonable to push for including that in the
standard. I don't think that blessing any other string type is going
to be very successful *without* OverloadedStrings, and I think that
Duncan is right that we want to introduce a new type before removing
the old one.
With regards to performance of fromString, I feel like if it was a
serious problem (and how many really big strings are going to be built
that way?) then an effort to do some special-case inlining (after all,
the parameters are constant and specified at compile time) might be
With regards to a general string API, I don't think a typeclass is the
correct solution (except for string literals); my view is that things
like ListLike may be practical but are awkward to use, and ambiguity
problems only make things more upsetting. I think we should just take
the abstract Text type and API, and leave implementors to do whatever
they want behind that.
More information about the Haskell-prime