[Haskell-cafe] Abandoning String = [Char]?
Clinton Mead
clintonmead at gmail.com
Tue May 19 05:19:11 UTC 2015
I've noticed improved list performance in GHC 7.10.1. In GHC 7.8, a simple
"sum" function worked faster on a "Stream" than a List, a Stream being a
data type with a state and successor function. The List version was around
10 times slower than the stream version when it came to summing Ints.
However GHC 7.10.1 compiles the list away, so the list version, stream
version, and accumulating parameter recursive function version now all run
in the same time.
If GHC continues to learn to optimise away lists effectively, [Char] may
not be a performance issue after all.
On Tue, May 19, 2015 at 2:47 PM, Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
wrote:
> On 05/18/2015 11:44 PM, Andrew Gibiansky wrote:
> > Hey all,
> >
> > In the earlier haskell-cafe discussion of IsString, someone mentioned
> that
> > it would be nice to abandon [Char] as the blessed string type in Haskell.
> > I've thought about this on and off for a while now, and think that the
> fact
> > that [Char] is the default string type is a really big issue (for
> example,
> > it gives beginners the idea that Haskell is incredibly slow, because
> > everything that involves string processing is using linked lists).
> >
> > I am not proposing anything, but am curious as to what already has been
> > discussed:
>
> Just me few cents below.
>
> > 1. Has the possibility of migrating away from [Char] been investigated
> > before?
>
> Migrating away to what?
>
> > 2. What gains could we see in ease of use, performance, etc, if [Char]
> was
> > deprecated?
>
> Deprecated in favour of what?
>
> > 3. What could replace [Char], while retaining the same ease of use for
> > writing string manipulation functions (pattern matching, etc)?
>
> ViewPatterns could let us imitate the pattern match at least but you'd
> still have to reconstruct from a list on RHS. Basically to me you're
> asking whether we can work with lists, using usual list things including
> constructors and presumably all list-y functions but without using
> lists… We either want one or another ;). But depending on what we want
> and if you're willing to give up the : and [] syntax, one could probably
> do well here anyway. But in any scenario, you'd be breaking every piece
> of code using String ever anyway.
>
> > 4. Is there any sort of migration path that would make this change
> feasible
> > in mainline Haskell in the medium term (2-5 years)?
>
> I don't think we'll ever see String changed in any significant way by
> default unless great pains are taken to do so. As I mention, you'd
> probably be breaking everything using String. If you don't want to work
> with a list of characters then use a different thing, most likely Text.
>
> Honestly, if your only motivation is that beginners might get a wrong
> idea, I don't think anything along your questions is even worth
> considering. Usually it takes few minutes top to tell a newbie in
> #haskell that they probably want Text or whatever, if they even care.
> Trying very hard to change what we already have and still make it as
> accessible as it is today is simply something I can't justify in any way
> I try.
>
> > Thanks! I would welcome any references or links that my cursory googling
> > has failed to find.
> >
> > -- Andrew
> >
> >
>
> --
> Mateusz K.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150519/a697137a/attachment.html>
More information about the Haskell-Cafe
mailing list