diff options
author | Daniel Rogozin <daniel.rogozin@serokell.io> | 2020-05-27 13:35:24 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-06 09:26:51 -0500 |
commit | 7f3524efcbd58ca6837ec0ffca6ddd121d64e4de (patch) | |
tree | aa296d28ed6475799ef369b0608736afcb467495 /compiler/GHC/Data | |
parent | 640a3ece333d1b0d0af8f353c3e1df9dd0cb9ef3 (diff) | |
download | haskell-7f3524efcbd58ca6837ec0ffca6ddd121d64e4de.tar.gz |
The Char kind (#11342)
Co-authored-by: Rinat Stryungis <rinat.stryungis@serokell.io>
Implement GHC Proposal #387
* Parse char literals 'x' at the type level
* New built-in type families CmpChar, ConsSymbol, UnconsSymbol
* New KnownChar class (cf. KnownSymbol and KnownNat)
* New SomeChar type (cf. SomeSymbol and SomeNat)
* CharTyLit support in template-haskell
Updated submodules: binary, haddock.
Metric Decrease:
T5205
haddock.base
Metric Increase:
Naperian
T13035
Diffstat (limited to 'compiler/GHC/Data')
-rw-r--r-- | compiler/GHC/Data/FastString.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/GHC/Data/FastString.hs b/compiler/GHC/Data/FastString.hs index 90d1c61594..d9363fe2e4 100644 --- a/compiler/GHC/Data/FastString.hs +++ b/compiler/GHC/Data/FastString.hs @@ -72,6 +72,7 @@ module GHC.Data.FastString -- ** Deconstruction unpackFS, -- :: FastString -> String + unconsFS, -- :: FastString -> Maybe (Char, FastString) -- ** Encoding zEncodeFS, @@ -608,6 +609,12 @@ headFS fs = head $ unpackFS fs consFS :: Char -> FastString -> FastString consFS c fs = mkFastString (c : unpackFS fs) +unconsFS :: FastString -> Maybe (Char, FastString) +unconsFS fs = + case unpackFS fs of + [] -> Nothing + (chr : str) -> Just (chr, mkFastString str) + uniqueOfFS :: FastString -> Int uniqueOfFS fs = uniq fs |