packages feed

string-interpolate-0.3.0.1 / src / lib / Data / String / Interpolate / Conversion / TextSink.hs

{-# OPTIONS -Wno-orphans           #-}{-# LANGUAGE CPP                   #-}{-# LANGUAGE DataKinds             #-}{-# LANGUAGE FlexibleInstances     #-}{-# LANGUAGE MultiParamTypeClasses #-}{-# LANGUAGE Strict                #-}{-# LANGUAGE TypeFamilies          #-}module Data.String.Interpolate.Conversion.TextSink  ()whereimport 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 ( bsToTextBuilder, lbsToTextBuilder )#ifdef TEXT_BUILDER#elseimport qualified Data.Text.Lazy#endif---------------------- SINK DEFINITIONS--------------------#ifdef TEXT_BUILDERinstance InterpSink 'True T.Text where  type Builder 'True T.Text = LT.Builder  ofString _ = B . LT.fromString  build _ (B l) (B r) = B $ l `mappend` r  finalize _ = LT.toStrict . LT.toLazyText . unBinstance InterpSink 'True LT.Text where  type Builder 'True LT.Text = LT.Builder  ofString _ = B . LT.fromString  build _ (B l) (B r) = B $ l `mappend` r  finalize _ = LT.toLazyText . unB#elseinstance InterpSink 'True T.Text where  type Builder 'True T.Text = T.Text  ofString _ = B . T.pack  build _ (B l) (B r) = B $ l `mappend` r  finalize _ = unBinstance InterpSink 'True LT.Text where  type Builder 'True LT.Text = LT.Text  ofString _ = B . LT.pack  build _ (B l) (B r) = B $ l `mappend` r  finalize _ = unB#endifinstance InterpSink 'True LT.Builder where  type Builder 'True LT.Builder = LT.Builder  ofString _ = B . LT.fromString  build _ (B l) (B r) = B $ l `mappend` r  finalize _ = unB---------------------- INTERPOLATION INSTANCES--------------------#ifdef TEXT_BUILDERinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src T.Text where  interpolate _ = B . LT.fromString . showinstance {-# OVERLAPS #-} Interpolatable 'True Char T.Text where  interpolate _ = B . LT.singletoninstance {-# OVERLAPS #-} Interpolatable 'True String T.Text where  interpolate _ = B . LT.fromStringinstance {-# OVERLAPS #-} Interpolatable 'True T.Text T.Text where  interpolate _ = B . LT.fromTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text T.Text where  interpolate _ = B . LT.fromLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder T.Text where  interpolate _ = Binstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString T.Text where  interpolate _ = B . bsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString T.Text where  interpolate _ = B . lbsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder T.Text where  interpolate _ = B . lbsToTextBuilder . LB.toLazyByteStringinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src LT.Text where  interpolate _ = B . LT.fromString . showinstance {-# OVERLAPS #-} Interpolatable 'True Char LT.Text where  interpolate _ = B . LT.singletoninstance {-# OVERLAPS #-} Interpolatable 'True String LT.Text where  interpolate _ = B . LT.fromStringinstance {-# OVERLAPS #-} Interpolatable 'True T.Text LT.Text where  interpolate _ = B . LT.fromTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text LT.Text where  interpolate _ = B . LT.fromLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder LT.Text where  interpolate _ = Binstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString LT.Text where  interpolate _ = B . bsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString LT.Text where  interpolate _ = B . lbsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder LT.Text where  interpolate _ = B . lbsToTextBuilder . LB.toLazyByteString#elseinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src T.Text where  interpolate _ = B . T.pack . showinstance {-# OVERLAPS #-} Interpolatable 'True Char T.Text where  interpolate _ = B . T.singletoninstance {-# OVERLAPS #-} Interpolatable 'True String T.Text where  interpolate _ = B . T.packinstance {-# OVERLAPS #-} Interpolatable 'True T.Text T.Text where  interpolate _ = Binstance {-# OVERLAPS #-} Interpolatable 'True LT.Text T.Text where  interpolate _ = B . LT.toStrictinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder T.Text where  interpolate _ = B . LT.toStrict . LT.toLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString T.Text where  interpolate _ = B . LT.toStrict . LT.toLazyText . bsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString T.Text where  interpolate _ = B . LT.toStrict . LT.toLazyText . lbsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder T.Text where  interpolate _ = B . LT.toStrict . LT.toLazyText . lbsToTextBuilder . LB.toLazyByteStringinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src LT.Text where  interpolate _ = B . LT.pack . showinstance {-# OVERLAPS #-} Interpolatable 'True Char LT.Text where  interpolate _ = B . Data.Text.Lazy.singletoninstance {-# OVERLAPS #-} Interpolatable 'True String LT.Text where  interpolate _ = B . LT.packinstance {-# OVERLAPS #-} Interpolatable 'True T.Text LT.Text where  interpolate _ = B . LT.fromStrictinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text LT.Text where  interpolate _ = Binstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder LT.Text where  interpolate _ = B . LT.toLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString LT.Text where  interpolate _ = B . LT.toLazyText . bsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString LT.Text where  interpolate _ = B . LT.toLazyText . lbsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder LT.Text where  interpolate _ = B . LT.toLazyText . lbsToTextBuilder . LB.toLazyByteString#endifinstance {-# OVERLAPPABLE #-} Show src => Interpolatable 'True src LT.Builder where  interpolate _ = B . LT.fromString . showinstance {-# OVERLAPS #-} Interpolatable 'True Char LT.Builder where  interpolate _ = B . LT.singletoninstance {-# OVERLAPS #-} Interpolatable 'True String LT.Builder where  interpolate _ = B . LT.fromStringinstance {-# OVERLAPS #-} Interpolatable 'True T.Text LT.Builder where  interpolate _ = B . LT.fromTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Text LT.Builder where  interpolate _ = B . LT.fromLazyTextinstance {-# OVERLAPS #-} Interpolatable 'True LT.Builder LT.Builder where  interpolate _ = Binstance {-# OVERLAPS #-} Interpolatable 'True B.ByteString LT.Builder where  interpolate _ = B . bsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.ByteString LT.Builder where  interpolate _ = B . lbsToTextBuilderinstance {-# OVERLAPS #-} Interpolatable 'True LB.Builder LT.Builder where  interpolate _ = B . lbsToTextBuilder . LB.toLazyByteString