# Text-2.0 with UTF8 is finally released!

**URL:** https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840
**Category:** Announcements
**Created:** [December 24, 2021, 7:15pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840 "2021-12-24T19:15:05Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Bodigrim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bodigrim/32/1457_2.png) [@Bodigrim](https://discourse.haskell.org/u/Bodigrim)
#### Post date: [December 24, 2021, 7:15pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/1 "2021-12-24T19:15:05Z")

</div>

I’m happy to announce that `text-2.0` with UTF-8 underlying representation has been finally released: [https://hackage.haskell.org/package/text-2.0](https://hackage.haskell.org/package/text-2.0). The release is identical to `rc2`, circulated [earlier](https://www.reddit.com/r/haskell/comments/rdj1fv/text20rc2_with_utf8_underlying_representation_is/).

Changelog: [https://hackage.haskell.org/package/text-2.0/changelog](https://hackage.haskell.org/package/text-2.0/changelog)

Please give it a try. Here is a `cabal.project` template: [https://gist.github.com/Bodigrim/9834568f075be36a1c65e7aaba6a15db](https://gist.github.com/Bodigrim/9834568f075be36a1c65e7aaba6a15db)

This work would not be complete without a blazingly-fast UTF-8 validator, submitted by Koz Ross into [`bytestring-0.11.2.0`](https://hackage.haskell.org/package/bytestring-0.11.2.0/docs/Data-ByteString.html#v:isValidUtf8), whose contributions were sourced via HF as an in-kind donation from MLabs. I would like to thank Emily Pillmore for encouraging me to take on this project, helping with the proposal and permissions. I’m grateful to my fellow `text` maintainers, who’ve been carefully reviewing my work in course of the last six months, as well as helpful and responsive maintainers of downstream packages and GHC developers. Thanks all, it was a pleasant journey!

---

<div class="post-metadata">

### Author: ![gilmi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/gilmi/32/45_2.png) [@gilmi](https://discourse.haskell.org/u/gilmi)
#### Post date: [December 24, 2021, 8:36pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/2 "2021-12-24T20:36:10Z")

</div>

Thank you very much for all of your hard work, Bodigrim and everyone involved.  
Congratulations on the release!

---

<div class="post-metadata">

### Author: ![vmchale](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/vmchale/32/86_2.png) [@vmchale](https://discourse.haskell.org/u/vmchale)
#### Post date: [December 25, 2021, 5:57pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/3 "2021-12-25T17:57:00Z")

</div>

Wow!! Good stuff. Just tested it locally on one of my projects and it works 🙂

---

<div class="post-metadata">

### Author: ![ketzacoatl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ketzacoatl/32/1203_2.png) [@ketzacoatl](https://discourse.haskell.org/u/ketzacoatl)
#### Post date: [December 29, 2021, 1:13pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/4 "2021-12-29T13:13:56Z")

</div>

@Bodigrim,

Thank you for your efforts to see this thru!

I don’t have the full picture, so forgive my ignorance on some of this… I am curious, how far down the road does this push us WRT simplifying our String/Text madness in Haskell?

---

<div class="post-metadata">

### Author: ![Bodigrim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bodigrim/32/1457_2.png) [@Bodigrim](https://discourse.haskell.org/u/Bodigrim)
#### Post date: [December 29, 2021, 7:17pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/5 "2021-12-29T19:17:53Z")

</div>

I would not say that `String` is a weakness, it is actually a strength. There is no way not to have `Char` in `base` and there is no way not to have lists, so `[Char]` will be always available. It totally makes sense for `base` not to introduce more entities than needed and just use `[Char]` to represent strings. It’s also a wonderful educational tool: while there are certain pitfalls with `readFile :: String -> IO String`, a novice can start writing something useful knowing only about lists and basic polymorphic operations on them. This is as simple as possible.

---

<div class="post-metadata">

### Author: ![wiz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/wiz/32/2408_2.png) [@wiz](https://discourse.haskell.org/u/wiz)
#### Post date: [January 20, 2022, 8:50am UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/8 "2022-01-20T08:50:24Z")

</div>

It is a weakness in a sense of making “bad” things easier than “good”.

You start with `[Char]`, then you add some `printf`s, read a file or two, show some things… and then you find yourself deeply committed to your training wheels.

Yes, I know about _some_ use cases where `[Char]` is okay. But you need to be on a lookout to prevent it from leaking into all the other places.

I’m even fine with the `[Char]` type by itself. The madness lies in the `String`.

---

<div class="post-metadata">

### Author: ![ketzacoatl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ketzacoatl/32/1203_2.png) [@ketzacoatl](https://discourse.haskell.org/u/ketzacoatl)
#### Post date: [January 20, 2022, 5:53pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/9 "2022-01-20T17:53:01Z")

</div>

Yea, I would agree with @wiz on this.

In practice, `String` and `[Char]` are warts that make implementations more complex, more verbose, and less straightforward for _practical_ use of Haskell in production. They also complicate teaching/learning Haskell to/for beginners. To say otherwise is not wrong, but obviously not the conclusion you would arrive at as a new Haskeller uninhibited by experiential baggage from Haskell of yesteryear.

> The madness lies in the `String`.

I’d argue the madness lies in the prolific use of `String` in the ecosystem, starting with `base` and extending to the rest of our “standard library”.

---

<div class="post-metadata">

### Author: ![Bodigrim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bodigrim/32/1457_2.png) [@Bodigrim](https://discourse.haskell.org/u/Bodigrim)
#### Post date: [January 20, 2022, 8:49pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/10 "2022-01-20T20:49:47Z")

</div>

My point is that we cannot remove `String` from `base`, because `Char` and `[]` would always remain there.

The ecosystem should use `String` less indeed. The biggest hurdle here is file API, which is now targeted by AFP proposal, led by @hasufell.

---

<div class="post-metadata">

### Author: ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)
#### Post date: [January 20, 2022, 9:04pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/11 "2022-01-20T21:04:22Z")

</div>

> [@Bodigrim](#):
>
> AFP proposal

I didn’t immediately know what you meant, so, for others, it is the [abstract file path proposal](http://discourse.haskell.org/t/reviving-the-abstract-filepath-proposal-afpp-in-user-space/2344).

---

<div class="post-metadata">

### Author: ![fosskers](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/fosskers/32/3744_2.png) [@fosskers](https://discourse.haskell.org/u/fosskers)
#### Post date: [January 20, 2022, 10:58pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/12 "2022-01-20T22:58:00Z")

</div>

Hey so what’s the upgrade path for this for library authors? Should I go around and make `text-2.0` the lower bound for all my libs?

---

<div class="post-metadata">

### Author: ![Bodigrim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/bodigrim/32/1457_2.png) [@Bodigrim](https://discourse.haskell.org/u/Bodigrim)
#### Post date: [January 20, 2022, 11:51pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/13 "2022-01-20T23:51:03Z")

</div>

Why make it _lower_ bound? `text` is a boot library, so GHC \< 9.4 will stick to `text-1.2`.

The majority of packages do not need any changes to upgrade, just relax an upper bound to `text < 2.1`. A template `cabal.project` can be found here: [Template cabal.project with text-2.0 support · GitHub](https://gist.github.com/Bodigrim/9834568f075be36a1c65e7aaba6a15db)

---

<div class="post-metadata">

### Author: ![fosskers](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/fosskers/32/3744_2.png) [@fosskers](https://discourse.haskell.org/u/fosskers)
#### Post date: [January 21, 2022, 12:55am UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/14 "2022-01-21T00:55:57Z")

</div>

And I see `aeson` doing this:

```haskell
    , text >=1.2.3.0 && <1.3 || >=2.0 && <2.1

```

So I’ll follow that pattern. Thank you!

---

<div class="post-metadata">

### Author: ![gilmi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/gilmi/32/45_2.png) [@gilmi](https://discourse.haskell.org/u/gilmi)
#### Post date: [January 21, 2022, 7:58am UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/15 "2022-01-21T07:58:01Z")

</div>

I don’t understand why we can’t (conceptually) remove `type String = [Char]`, change all the relevant functions such as `putStrLn` to use `Text` instead, and make string literals have the type `Text`?

This would pretty much solve the string situation afaict (but of course the cost of breakage would be very high).

Am I missing something here?

---

<div class="post-metadata">

### Author: ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)
#### Post date: [January 21, 2022, 10:13am UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/16 "2022-01-21T10:13:03Z")

</div>

I think the problem is deeper than just choosing a type. Given that that correct way to interact with a terminal depends on the mode that terminal is in I don’t think there is a unique choice that works properly. For example

```haskell
% cat /tmp/test.hs && ghc /tmp/test.hs && LC_ALL=C /tmp/test
main = putStrLn "💔"
Loaded package environment from /home/tom/.ghc/x86_64-linux-8.10.7/environments/default
test: <stdout>: commitBuffer: invalid argument (invalid character)

```

I think the system needs rethinking from the ground up.

---

<div class="post-metadata">

### Author: ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)
#### Post date: [January 21, 2022, 10:24am UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/17 "2022-01-21T10:24:57Z")

</div>

I think one easy solution is to [just always default to utf8](https://serokell.io/blog/haskell-with-utf8), or does that not solve this problem?

---

<div class="post-metadata">

### Author: ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)
#### Post date: [January 21, 2022, 10:34am UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/18 "2022-01-21T10:34:31Z")

</div>

That would require that anyone using a Haskell system must have configured their terminal for UTF8 which seems rather a strong requirement.

---

<div class="post-metadata">

### Author: ![ketzacoatl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ketzacoatl/32/1203_2.png) [@ketzacoatl](https://discourse.haskell.org/u/ketzacoatl)
#### Post date: [January 21, 2022, 4:38pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/19 "2022-01-21T16:38:55Z")

</div>

It seems, the hardest part of this fix is figuring out the best course of action.

Maybe we should advocate for the HF Technical WG take on this next step?

Given how GHC breaks our world from time to time, and given how “graceful migrations” is a mostly solved problem, I don’t see why we couldn’t figure this out if we try and push hard on it.

Think of how nice it will be to not need to go through all the extra hoops when using `Text`!

---

<div class="post-metadata">

### Author: ![fosskers](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/fosskers/32/3744_2.png) [@fosskers](https://discourse.haskell.org/u/fosskers)
#### Post date: [January 21, 2022, 6:03pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/20 "2022-01-21T18:03:07Z")

</div>

A number of languages enforce UTF8 these days, so I don’t think it’s cruel to expect it.

---

<div class="post-metadata">

### Author: ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)
#### Post date: [January 21, 2022, 8:38pm UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/21 "2022-01-21T20:38:55Z")

</div>

Do they even force UTF8 for interacting with the terminal? I’m personally in favour of requiring UTF8 everywhere but I’m not sure if there are other encodings in popular use on interactive terminals.

---

<div class="post-metadata">

### Author: ![wiz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/wiz/32/2408_2.png) [@wiz](https://discourse.haskell.org/u/wiz)
#### Post date: [January 22, 2022, 9:39am UTC](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840/22 "2022-01-22T09:39:57Z")

</div>

Yeah, lots of environments have terminals and locales misconfigured. And then there’s a C/C.UTF8 fustercluck.

Personally I’d rather see mojibake once in a while than have some script/build crashed for printing pretty unicode lines.

[Next page](https://discourse.haskell.org/t/text-2-0-with-utf8-is-finally-released/3840.md?page=2)
