summaryrefslogtreecommitdiff
path: root/compiler/GHC/Data/FastString.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Data/FastString.hs')
-rw-r--r--compiler/GHC/Data/FastString.hs7
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