<div dir="ltr"><div>Carter, that is a very good suggestion!</div><div><br></div>I imagine that a combination of PatternSynonyms and OverloadedLists could be used to completely abstract the list notation. This would have to happen to <i>all</i> Haskell source code, though.<div><br></div><div>Right now we have the following elements of list syntax:</div><div><ul><li>Types, e.g. [Char]</li><li>Construction via literals, [1, 2, 3]</li><li>Construction via pattern matching, 1 : 2 : []</li><li>Enumerations, [1..3], [1..], [1,3..]</li><li>Pattern matching, let (x:xs) = [1..]</li></ul><div>These are currently somewhat handled by</div></div><div><ul><li>OverloadedLists: Construction via literals</li><li>Enum typeclass: Enumerations</li></ul><div>We could handle the others partially, by allowing PatternSynonyms to replace (:) somehow, both for construction and pattern matching.</div></div><div><br></div><div>The [Char] usage does not need to be replaced. Then String could be changed to something else easily.</div><div><br></div><div>Looking at it this way, it makes the proposal seem much more doable. These could be bundled into a single extension -XPackedString, or something like that.</div><div><br></div><div>It would be interesting to formulate this into a full-fledged proposal, if only as an exploratory venture (I certainly do not have the time to follow through on this myself).</div><div><br></div><div>-- Andrew</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 22, 2015 at 11:57 PM, Carter Schonwald <span dir="ltr"><<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">one direction that this thread has *COMPLETELY* overlooked is the following:<div><br></div><div>could we use pattern synonyms or something along those lines to make the migration to Text or the like more seemless?</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 22, 2015 at 1:55 PM, Mike Meyer <span dir="ltr"><<a href="mailto:mwm@mired.org" target="_blank">mwm@mired.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Having just finished converting my Haskell shell-scripting tool from Strjng to Text/ByteString, might I suggest that such a change would create fewer problems after a Prelude rework to something like ClassyPrelude? Using ClassyPrelude meant that a lot of the code that worked with String worked just fine with Text and ByteString. I had more fixes due to having used partial function than with no longer having List's of chars.<div><div><div><br><div><div class="gmail_extra"><div class="gmail_quote">On Fri, May 22, 2015 at 12:37 PM, Andrew Gibiansky <span dir="ltr"><<a href="mailto:andrew.gibiansky@gmail.com" target="_blank">andrew.gibiansky@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Mario,<div><br></div><div>Thank you for that detailed write-up. That's exactly the sort of thing I was looking for.</div><div><br></div><div>I imagine a path like the one you describe is possible, but very, very difficult, and likely the effort could be better spent elsewhere. </div><div><br></div><div>I imagine an alternate route (that would have immediate gains in the near future, and wouldn't be a long-term transition plan) would be to have a `text-base` package, which exports everything `base` does, exporting `Text` instead of `String`. Then base packages off that instead of `base`, thus ensuring you do not rely on []-manipulation for `String` (you should still have full compatibility with normal `base`). </div><div><br></div><div>Anyway, hard choices all around, for no 100% clear gain, so I personally do not envision this happening any time soon. Oh well...</div><div><br></div><div>-- Andrew</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 22, 2015 at 6:07 PM, Michal Antkiewicz <span dir="ltr"><<a href="mailto:mantkiew@gsd.uwaterloo.ca" target="_blank">mantkiew@gsd.uwaterloo.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Mario, thanks for that great writeup. <br><br>The switch can only happen if there's a way to make the old code somehow transparently work the same or better in the new setup. <br><br>Maybe some GHC magic could bring the string operations to Prim Ops and transparently switch the underlying representation to Text from [Char]. Basically, Text would have to become a built in primitive, not a library.<br><br clear="all"><div class="gmail_extra"><div><div><div dir="ltr"><div>Michał <br></div></div></div></div><div><div>
<br><div class="gmail_quote">On Fri, May 22, 2015 at 10:29 AM, Mario Blažević <span dir="ltr"><<a href="mailto:mblazevic@stilo.com" target="_blank">mblazevic@stilo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 15-05-18 06:44 PM, Andrew Gibiansky wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hey all,<br>
<br>
In the earlier haskell-cafe discussion of IsString, someone mentioned<br>
that it would be nice to abandon [Char] as the blessed string type in<br>
Haskell. I've thought about this on and off for a while now, and think<br>
that the fact that [Char] is the default string type is a really big<br>
issue (for example, it gives beginners the idea that Haskell is<br>
incredibly slow, because everything that involves string processing is<br>
using linked lists).<br>
<br>
I am not proposing anything, but am curious as to what already has been<br>
discussed:<br>
<br>
1. Has the possibility of migrating away from [Char] been investigated<br>
before?<br>
</blockquote>
<br></span>
        No, not seriously as far as I'm aware. That ship has sailed a long time ago. Still, as I have actually thought about that, I'll give you an outline of a possible process.<span><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2. What gains could we see in ease of use, performance, etc, if [Char]<br>
was deprecated?<br>
</blockquote>
<br></span>
        They could be very significant for any code that took advantage of the new type, but the existing code would not benefit that much. But then, any new Haskell code can already use Text where performance matters.<span><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
3. What could replace [Char], while retaining the same ease of use for<br>
writing string manipulation functions (pattern matching, etc)?<br>
</blockquote>
<br></span>
        You would not have the same ease of use exactly. The options would lie between two extremes. At one end, you can have a completely opaque String type with fromChars/toChars operations and nothing else. At the other end, you'd implement all operations useful on strings so there would never be any need to convert between String and [Char].<br>
<br>
        The first extreme would be mostly useless from the performance point of view, but with some GHC magic perhaps it could be made a viable upgrade path. The compiler would have to automatically insert the implicit fromChars/toChars conversion whenever necessary, and I expect that some of the existing Haskell code would still be broken.<br>
<br>
        Once you have an opaque String type, you can think about improving the performance. A more efficient instance of Monoid String would be a good start, especially since it wouldn't break backward compatibility. Unfortunately that is the only [Char] instance in wide use that can be easily optimized. Perhaps Foldable could be made to work with even more compiler magic, but I doubt it would be worth the effort.<br>
<br>
        If you add more operations on String that don't require<span><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
4. Is there any sort of migration path that would make this change<br>
feasible in mainline Haskell in the medium term (2-5 years)?<br>
</blockquote>
<br></span>
        Suppose GHC 7.12 were to bring Text into the core libraries, change Prelude to declare type String = Text, and sprinkle some magic compiler dust to make the explicit Text <-> Char conversions unnecessary.<br>
<br>
        The existing Haskell code would almost certainly perform worse overall. The only improved operations would be mappend on String, and possibly the string literal instantiation.<br>
<br>
        I don't think there's any chance to get this kind of change proposal accepted today. You'd have to make the pain worth the gain.<br>
The only viable path is to ensure beforehand that the change improves more than just the mappend operation.<br>
<br>
        In other words, you'd have to get today's String to instantiate more classes in common with tomorrow's String, and you'd have to get the everyday Haskell code to use those classes instead of list manipulations.<br>
<br>
        The first tentative step towards the String type change would then be either the mono-traversable or my own monoid-subclasses package. They both define new type classes that are instantiated by both [Char] and Text. The main difference is that the former builds upon the Foldable foundation, the latter upon Monoid. They are both far from being a complete replacement for list manipulations. But any new code that used their operations would see a big improvement from the String type change.<br>
<br>
        Here, then, is the five-year plan you're asking for:<br>
<br>
Year one: Agree on the ideal set of type classes to bridge the gap between [Char] and Text.<br>
<br>
Year two: Bring the new type classes into the Prelude. Have all relevant types instantiate them. Everybody's updating their code in delight to use the new class methods.<br>
<br>
Year three: GHC issues warnings about using List-specific [], ++, null, take, drop, span, drop, etc, on String. Everybody's furiously updating their code.<br>
<br>
Year four: Add Text to the core libraries. The GHC magic to make the Text <-> [Char] convertions implicit is implemented and ready for testing but requires a pragma.<br>
<br>
Year five: Update Haskell language report. Flip the switch.<br>
<br>
So there. How feasible does that sound?<div><div><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div></div></div></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>