module Data.Text.Lazy.Builder ( Builder , LazyTextBuilder , toLazyText , toLazyTextWith , singleton , fromText , fromLazyText , fromString , flush ) whereimport qualified Data.Text as Simport qualified Data.Text.Lazy as Limport Data.Stringnewtype Builder = Builder (L.Text -> L.Text)type LazyTextBuilder = Builderinstance Eq Builder where a == b = toLazyText a == toLazyText binstance Ord Builder where compare a b = compare (toLazyText a) (toLazyText b)instance Semigroup Builder where Builder f <> Builder g = Builder (f . g)instance Monoid Builder where mempty = Builder idinstance IsString Builder where fromString = fromLazyText . L.packinstance Show Builder where show = show . toLazyTexttoLazyText :: Builder -> L.TexttoLazyText (Builder f) = f L.emptytoLazyTextWith :: Int -> Builder -> L.TexttoLazyTextWith _ = toLazyTextsingleton :: Char -> Buildersingleton = fromLazyText . L.singletonfromText :: S.Text -> BuilderfromText = fromLazyText . L.fromStrictfromLazyText :: L.Text -> BuilderfromLazyText t = Builder (t `L.append`)flush :: Builderflush = Builder id