Skip to content

Commit c5906d9

Browse files
committed
fixup! Implemented TH splices for validated ByteString literals
Henry Sylvain review fixups
1 parent a6b5c82 commit c5906d9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Data/ByteString/Internal/Type.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,8 @@ thLiteral :: String -> TH.Q (TH.TExp ByteString)
565565
#endif
566566
thLiteral "" = [||empty||]
567567
thLiteral s = case foldr' op (Octets 0 []) s of
568-
Octets !n ws -> liftTyped (unsafePackLenBytes n ws)
569-
Hichar !i !w -> liftCode $ fail $ "non-octet character '\\" ++
568+
Octets n ws -> liftTyped (unsafePackLenBytes n ws)
569+
Hichar i w -> liftCode $ fail $ "non-octet character '\\" ++
570570
show w ++ "' at offset: " ++ show i
571571
where
572572
op _ (Hichar !i !w) = Hichar (i + 1) w
@@ -586,7 +586,7 @@ data H2W = Hex {-# UNPACK #-} !Int [Word8]
586586
--
587587
-- > :set -XTemplateHaskell
588588
-- > ehloCmd :: ByteString
589-
-- > ehloCmd = $$(thLiteral "45484c4F")
589+
-- > ehloCmd = $$(thHexLiteral "45484c4F")
590590
--
591591
#if MIN_VERSION_template_haskell(2,17,0)
592592
thHexLiteral :: (MonadFail m, TH.Quote m) => String -> TH.Code m ByteString
@@ -596,9 +596,9 @@ thHexLiteral :: String -> TH.Q (TH.TExp ByteString)
596596
thHexLiteral "" = [||empty||]
597597
thHexLiteral s =
598598
case foldr' op (Hex 0 []) s of
599-
(Hex n ws) -> liftTyped (unsafePackLenBytes n ws)
600-
(Odd i _ _) -> liftCode $ fail $ "Odd input length: " ++ show (1 + 2 * i)
601-
(Bad i w) -> liftCode $ fail $ "Non-hexadecimal character '\\" ++
599+
Hex n ws -> liftTyped (unsafePackLenBytes n ws)
600+
Odd i _ _ -> liftCode $ fail $ "Odd input length: " ++ show (1 + 2 * i)
601+
Bad i w -> liftCode $ fail $ "Non-hexadecimal character '\\" ++
602602
show w ++ "' at offset: " ++ show i
603603
where
604604
-- Convert char to decimal digit value if result in [0, 9].

0 commit comments

Comments
 (0)