-show4 :: Integral i => i -> String
-show4 i
- | i >= 0 && i < 10 = "000" ++ show i
- | i >= 0 && i < 100 = "00" ++ show i
- | i >= 0 && i < 1000 = '0' : show i
- | i >= 0 && i < 10000 = show i
- | otherwise = error ("show4: the integer i must satisfy 0 <= i < 10000: " ++ show i)
-
-show2 :: Integral i => i -> String
-show2 i
- | i >= 0 && i < 10 = '0' : show i
- | i >= 0 && i < 100 = show i
- | otherwise = error ("show2: the integer i must satisfy 0 <= i < 100: " ++ show i)
-
-read4 :: (Stream s m Char, Num n) => ParsecT s u m n
-read4 = do n1 <- digit'
- n2 <- digit'
- n3 <- digit'
- n4 <- digit'
+show4 ∷ Integral i ⇒ i → AsciiBuilder
+{-# INLINE show4 #-}
+show4 = A.unsafeFromBuilder ∘ go
+ where
+ {-# INLINEABLE go #-}
+ go i | i ≥ 0 ∧ i < 10 = B.fromByteString "000" ⊕ BT.digit i
+ | i ≥ 0 ∧ i < 100 = B.fromByteString "00" ⊕ BT.integral i
+ | i ≥ 0 ∧ i < 1000 = B.fromByteString "0" ⊕ BT.integral i
+ | i ≥ 0 ∧ i < 10000 = BT.integral i
+ | otherwise = error ("show4: the integer i must satisfy 0 <= i < 10000: " ⧺ show i)
+
+show2 ∷ Integral i ⇒ i → AsciiBuilder
+{-# INLINE show2 #-}
+show2 = A.unsafeFromBuilder ∘ go
+ where
+ go i | i ≥ 0 ∧ i < 10 = B.fromByteString "0" ⊕ BT.digit i
+ | i ≥ 0 ∧ i < 100 = BT.integral i
+ | otherwise = error ("show2: the integer i must satisfy 0 <= i < 100: " ⧺ show i)
+
+show2' ∷ Integral i ⇒ i → AsciiBuilder
+{-# INLINE show2' #-}
+show2' = A.unsafeFromBuilder ∘ go
+ where
+ go i | i ≥ 0 ∧ i < 10 = B.fromByteString " " ⊕ BT.digit i
+ | i ≥ 0 ∧ i < 100 = BT.integral i
+ | otherwise = error ("show2': the integer i must satisfy 0 <= i < 100: " ⧺ show i)
+
+read4 ∷ Num n ⇒ Parser n
+{-# INLINEABLE read4 #-}
+read4 = do n1 ← digit'
+ n2 ← digit'
+ n3 ← digit'
+ n4 ← digit'