-
Notifications
You must be signed in to change notification settings - Fork 718
Description
cabal/Cabal-syntax/src/Distribution/Utils/ShortText.hs
Lines 95 to 96 in 0a2e68c
newtype ShortText = ST { unST :: BS.Short.ShortByteString } | |
deriving (Eq,Ord,Generic,Data,Typeable) |
Most of Cabal textual data (PackageName
, ModuleName
, etc.) are newtypes over ShortText
. This provides for compact storage, but almost any operation on them requires conversion to String
and back. Indeed, working with Unicode in ShortByteString
directly is painful.
Could we replace ShortByteString
by Text
in ShortText
?
newtype ShortText = ST { unST :: Data.Text.Text }
This would simplify boilerplate in Distribution.Utils.ShortText
and it would be trivial to expose more utilities to avoid ubiquitous conversions to String
. Potentially we can also parse directly into Text
(instead of parsing ByteString
and converting later).
Note that Cabal
already depends on text
via parsec
, so this move does not change dependency graph.
(Another option is to use text-short
, but this one is slightly less conservative. If the proposal is implemented, it would be trivial to swap text
and text-short
, as they provide almost the same API)
CC @phadej