+-- |Convert a 'ByteString' to an 'Exp' representing it as a literal.
+liftByteString ∷ ByteString → Q Exp
+liftByteString bs
+ = [| Strict.pack $(litE $ stringL $ Strict.unpack bs) |]
+
+-- |Convert a 'Lazy.ByteString' to an 'Exp' representing it as a
+-- literal.
+liftLazyByteString ∷ Lazy.ByteString → Q Exp
+liftLazyByteString = Lazy.foldrChunks f [| Lazy.Empty |]
+ where
+ f ∷ ByteString → Q Exp → Q Exp
+ f bs e = [| Lazy.Chunk $(liftByteString bs) $e |]
+
+-- |Convert an 'Ascii' to an 'Exp' representing it as a literal.
+liftAscii ∷ Ascii → Q Exp
+liftAscii a = [| A.unsafeFromByteString
+ $ unsafePerformIO
+ $ Strict.unsafePackAddressLen $len $ptr
+ |]
+ where
+ bs ∷ Strict.ByteString
+ bs = A.toByteString a
+
+ len, ptr ∷ Q Exp
+ len = lift $ Strict.length bs
+ ptr = litE $ stringPrimL $ Strict.unpack bs
+