{-# OPTIONS -Wno-orphans #-}{-# LANGUAGE CPP #-}{-# LANGUAGE DataKinds #-}{-# LANGUAGE FlexibleInstances #-}{-# LANGUAGE MultiParamTypeClasses #-}{-# LANGUAGE PackageImports #-}{-# LANGUAGE Strict #-}{-# LANGUAGE TypeFamilies #-}module Data.String.Interpolate.Conversion.ByteStringSink ()whereimport Data.Text.Conversionsimport qualified Data.ByteString as Bimport qualified Data.ByteString.Builder as LBimport qualified Data.ByteString.Lazy as LBimport qualified Data.Text as Timport qualified Data.Text.Lazy as LT hiding ( singleton )import qualified Data.Text.Lazy.Builder as LTimport Data.String.Interpolate.Conversion.Classesimport Data.String.Interpolate.Conversion.Encoding ( encodeCharUTF8 )---------------------- SINK DEFINITIONS--------------------#ifdef BYTESTRING_BUILDERinstance InterpSink 'True B.ByteString where type Builder 'True B.ByteString = LB.Builder ofString _ = B . LB.byteString . unUTF8 . convertText build _ (B l) (B r) = B $ l `mappend` r finalize _ = LB.toStrict . LB.toLazyByteString . unBinstance InterpSink 'True LB.ByteString where type Builder 'True LB.ByteString = LB.Builder ofString _ = B . LB.lazyByteString . unUTF8 . convertText build _ (B l) (B r) = B $ l `mappend` r finalize _ = LB.toLazyByteString . unB#elseinstance InterpSink 'True B.ByteString where type Builder 'True B.ByteString = B.ByteString ofString _ = B . unUTF8 . convertText build _ (B l) (B r) = B $ l `mappend` r finalize _ = unBinstance InterpSink 'True LB.ByteString where type Builder 'True LB.ByteString = LB.ByteString ofString _ = B . unUTF8 . convertText build _ (B l) (B r) = B $ l `mappend` r finalize _ = unB#endifinstance InterpSink 'True LB.Builder where type Builder 'True LB.Builder = LB.Builder ofString _ = B . LB.lazyByteString . unUTF8 . convertText build _ (B l) (B r) = B $ l `mappend` r finalize _ = unB---------------------- INTERPOLATION INSTANCES--------------------#ifdef BYTESTRING_BUILDERinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src B.ByteString where interpolate _ = B . LB.byteString . unUTF8 . convertText . showinstance {-# OVERLAPS #-} Interpolatable 'True Char B.ByteString where interpolate _ = B . encodeCharUTF8instance {-# OVERLAPS #-} Interpolatable 'True String B.ByteString where interpolate _ = B . LB.byteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True T.Text B.ByteString where interpolate _ = B . LB.byteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text B.ByteString where interpolate _ = B . LB.byteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder B.ByteString where interpolate _ = B . LB.byteString . unUTF8 . convertText . LT.toLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString B.ByteString where interpolate _ = B . LB.byteStringinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString B.ByteString where interpolate _ = B . LB.lazyByteStringinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder B.ByteString where interpolate _ = Binstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src LB.ByteString where interpolate _ = B . LB.lazyByteString . unUTF8 . convertText . showinstance {-# OVERLAPS #-} Interpolatable 'True Char LB.ByteString where interpolate _ = B . encodeCharUTF8instance {-# OVERLAPS #-} Interpolatable 'True String LB.ByteString where interpolate _ = B . LB.lazyByteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True T.Text LB.ByteString where interpolate _ = B . LB.lazyByteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text LB.ByteString where interpolate _ = B . LB.lazyByteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder LB.ByteString where interpolate _ = B . LB.lazyByteString . unUTF8 . convertText . LT.toLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString LB.ByteString where interpolate _ = B . LB.byteStringinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString LB.ByteString where interpolate _ = B . LB.lazyByteStringinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder LB.ByteString where interpolate _ = B#elseinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src B.ByteString where interpolate _ = B . unUTF8 . convertText . showinstance {-# OVERLAPS #-} Interpolatable 'True Char B.ByteString where interpolate _ = B . LB.toStrict . LB.toLazyByteString . encodeCharUTF8instance {-# OVERLAPS #-} Interpolatable 'True String B.ByteString where interpolate _ = B . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True T.Text B.ByteString where interpolate _ = B . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text B.ByteString where interpolate _ = B . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder B.ByteString where interpolate _ = B . unUTF8 . convertText . LT.toLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString B.ByteString where interpolate _ = Binstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString B.ByteString where interpolate _ = B . LB.toStrictinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder B.ByteString where interpolate _ = B . LB.toStrict . LB.toLazyByteStringinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src LB.ByteString where interpolate _ = B . unUTF8 . convertText . showinstance {-# OVERLAPS #-} Interpolatable 'True Char LB.ByteString where interpolate _ = B . LB.toLazyByteString . encodeCharUTF8instance {-# OVERLAPS #-} Interpolatable 'True String LB.ByteString where interpolate _ = B . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True T.Text LB.ByteString where interpolate _ = B . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text LB.ByteString where interpolate _ = B . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder LB.ByteString where interpolate _ = B . unUTF8 . convertText . LT.toLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString LB.ByteString where interpolate _ = B . LB.fromStrictinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString LB.ByteString where interpolate _ = Binstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder LB.ByteString where interpolate _ = B . LB.toLazyByteString#endifinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src LB.Builder where interpolate _ = B . LB.lazyByteString . unUTF8 . convertText . showinstance {-# OVERLAPS #-} Interpolatable 'True Char LB.Builder where interpolate _ = B . encodeCharUTF8instance {-# OVERLAPS #-} Interpolatable 'True String LB.Builder where interpolate _ = B . LB.lazyByteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True T.Text LB.Builder where interpolate _ = B . LB.lazyByteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text LB.Builder where interpolate _ = B . LB.lazyByteString . unUTF8 . convertTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder LB.Builder where interpolate _ = B . LB.lazyByteString . unUTF8 . convertText . LT.toLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString LB.Builder where interpolate _ = B . LB.byteStringinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString LB.Builder where interpolate _ = B . LB.lazyByteStringinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder LB.Builder where interpolate _ = B