+import Prelude hiding (last, mapM, null, reverse)
+import Prelude.Unicode
+import System.Directory
+import System.Time (ClockTime(..))
+
+-- |>>> splitBy (== ':') "ab:c:def"
+-- ["ab", "c", "def"]
+splitBy ∷ (a → Bool) → [a] → [[a]]
+{-# INLINEABLE splitBy #-}
+splitBy isSep src
+ = case break isSep src of
+ (last , [] ) → [last]
+ (first, _sep:rest) → first : splitBy isSep rest
+
+-- |>>> quoteStr "abc"
+-- "\"abc\""
+--
+-- >>> quoteStr "ab\"c"
+-- "\"ab\\\"c\""
+quoteStr ∷ Ascii → AsciiBuilder
+quoteStr str = A.toAsciiBuilder "\"" ⊕
+ go (A.toByteString str) (∅) ⊕
+ A.toAsciiBuilder "\""
+ where
+ go ∷ Strict.ByteString → AsciiBuilder → AsciiBuilder
+ go bs ab
+ = case Strict.break (≡ '"') bs of
+ (x, y)
+ | Strict.null y
+ → ab ⊕ b2ab x
+ | otherwise
+ → go (Strict.tail y)
+ (ab ⊕ b2ab x ⊕ A.toAsciiBuilder "\\\"")
+
+ b2ab ∷ Strict.ByteString → AsciiBuilder
+ b2ab = A.toAsciiBuilder ∘ A.unsafeFromByteString