Add `Distribution.Simple.Utils.ShortText` type (#3898)
commit993d20a2e9b8fb29aefaa2c266f31177a00a5ee6
authorHerbert Valerio Riedel <hvr@gnu.org>
Wed, 28 Sep 2016 21:16:53 +0000 (28 23:16 +0200)
committerGitHub <noreply@github.com>
Wed, 28 Sep 2016 21:16:53 +0000 (28 23:16 +0200)
treecc7006864dc42da9e6d8c4c77eaf96a8236bd367
parentbb2026c4dd6238338cfbcc4a34e3fa1f6868dc13
Add `Distribution.Simple.Utils.ShortText` type (#3898)

This implements a type with a compact representation of `[Char]`.

The data is stored internally as UTF8 in an 'Data.ByteString.Short.ShortByteString'
when compiled against `bytestring >= 0.10.4`, and otherwise in a
plain old `[Char]`.

`ShortByteString` is available only from `bytestring` 0.10.4 on, and GHC
7.8.4 was the first GHC to bundle `binary-0.10.4`. So this fallback
affects mostly only GHC 7.6 and older.

Note: Originally a strict `ByteString` was used as fallback for this patch. However, the
`[Char]` fallback avoids pinned memory and may be more preferable when dealing with
many small `ShortText`s
Cabal/Distribution/Simple/Utils.hs
Cabal/changelog
Cabal/tests/UnitTests/Distribution/Simple/Utils.hs