summaryrefslogtreecommitdiff
path: root/compiler/GHC/Data/FastString.hs
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2021-06-12 18:52:46 +0300
committerVladislav Zavialov <vlad.z.4096@gmail.com>2021-06-24 20:54:32 +0300
commit8866c88c8847c92b578b21a1153094925f83386f (patch)
tree1e38f7885cf24dd74b6a798728738160bc861ee9 /compiler/GHC/Data/FastString.hs
parent138b7a5775251c330ade870a0b8d1f5c4659e669 (diff)
downloadhaskell-wip/op-ws-consym.tar.gz
Fix -Woperator-whitespace for consym (part of #19372)wip/op-ws-consym
Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively, and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. I also took the liberty to do some refactoring, in particular related to NoLexicalNegationBit. Regression test included.
Diffstat (limited to 'compiler/GHC/Data/FastString.hs')
-rw-r--r--compiler/GHC/Data/FastString.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/GHC/Data/FastString.hs b/compiler/GHC/Data/FastString.hs
index 9ed0a38df3..3c52de1fae 100644
--- a/compiler/GHC/Data/FastString.hs
+++ b/compiler/GHC/Data/FastString.hs
@@ -89,6 +89,7 @@ module GHC.Data.FastString
isUnderscoreFS,
lexicalCompareFS,
uniqCompareFS,
+ headByteFS,
-- ** Outputting
hPutFS,
@@ -609,6 +610,10 @@ headFS fs
| SBS.null $ fs_sbs fs = panic "headFS: Empty FastString"
headFS fs = head $ unpackFS fs
+-- the first byte of the Modified UTF-8 encoded string
+headByteFS :: FastString -> Word8
+headByteFS fs = SBS.index (fs_sbs fs) 0
+
consFS :: Char -> FastString -> FastString
consFS c fs = mkFastString (c : unpackFS fs)