text-builder 0.6.8 → 0.6.9
raw patch · 2 files changed
+47/−42 lines, 2 filesdep ~text-builder-dev
Dependency ranges changed: text-builder-dev
Files
- library/TextBuilder.hs +45/−40
- text-builder.cabal +2/−2
library/TextBuilder.hs view
@@ -1,5 +1,6 @@ module TextBuilder- ( Builder,+ ( TextBuilder,+ Builder, -- * Accessors run,@@ -75,179 +76,183 @@ -- | -- Specification of how to efficiently construct strict 'Text'. -- Provides instances of 'Semigroup' and 'Monoid', which have complexity of /O(1)/.-newtype Builder- = Builder Dev.TextBuilder+newtype TextBuilder+ = TextBuilder Dev.TextBuilder deriving (Show, IsString, Semigroup, Monoid) +{-# DEPRECATED Builder "Use TextBuilder instead" #-}++type Builder = TextBuilder+ -- | Get the amount of characters {-# INLINE length #-}-length :: Builder -> Int+length :: TextBuilder -> Int length = coerce Dev.length -- | Check whether the builder is empty {-# INLINE null #-}-null :: Builder -> Bool+null :: TextBuilder -> Bool null = coerce Dev.null -- | Execute a builder producing a strict text-run :: Builder -> Text+run :: TextBuilder -> Text run = coerce Dev.buildText -- ** Output IO -- | Put builder, to stdout-putToStdOut :: Builder -> IO ()+putToStdOut :: TextBuilder -> IO () putToStdOut = coerce Dev.putToStdOut -- | Put builder, to stderr-putToStdErr :: Builder -> IO ()+putToStdErr :: TextBuilder -> IO () putToStdErr = coerce Dev.putToStdErr -- | Put builder, followed by a line, to stdout-putLnToStdOut :: Builder -> IO ()+putLnToStdOut :: TextBuilder -> IO () putLnToStdOut = coerce Dev.putLnToStdOut -- | Put builder, followed by a line, to stderr-putLnToStdErr :: Builder -> IO ()+putLnToStdErr :: TextBuilder -> IO () putLnToStdErr = coerce Dev.putLnToStdErr -- * Constructors -- | Unicode character {-# INLINE char #-}-char :: Char -> Builder+char :: Char -> TextBuilder char = coerce Dev.char -- | Unicode code point {-# INLINE unicodeCodePoint #-}-unicodeCodePoint :: Int -> Builder+unicodeCodePoint :: Int -> TextBuilder unicodeCodePoint = coerce Dev.unicodeCodePoint -- | Single code-unit UTF-16 character {-# INLINEABLE utf16CodeUnits1 #-}-utf16CodeUnits1 :: Word16 -> Builder+utf16CodeUnits1 :: Word16 -> TextBuilder utf16CodeUnits1 = coerce Dev.utf16CodeUnits1 -- | Double code-unit UTF-16 character {-# INLINEABLE utf16CodeUnits2 #-}-utf16CodeUnits2 :: Word16 -> Word16 -> Builder+utf16CodeUnits2 :: Word16 -> Word16 -> TextBuilder utf16CodeUnits2 = coerce Dev.utf16CodeUnits2 -- | Single code-unit UTF-8 character {-# INLINE utf8CodeUnits1 #-}-utf8CodeUnits1 :: Word8 -> Builder+utf8CodeUnits1 :: Word8 -> TextBuilder utf8CodeUnits1 = coerce Dev.utf8CodeUnits1 -- | Double code-unit UTF-8 character {-# INLINE utf8CodeUnits2 #-}-utf8CodeUnits2 :: Word8 -> Word8 -> Builder+utf8CodeUnits2 :: Word8 -> Word8 -> TextBuilder utf8CodeUnits2 = coerce Dev.utf8CodeUnits2 -- | Triple code-unit UTF-8 character {-# INLINE utf8CodeUnits3 #-}-utf8CodeUnits3 :: Word8 -> Word8 -> Word8 -> Builder+utf8CodeUnits3 :: Word8 -> Word8 -> Word8 -> TextBuilder utf8CodeUnits3 = coerce Dev.utf8CodeUnits3 -- | UTF-8 character out of 4 code units {-# INLINE utf8CodeUnits4 #-}-utf8CodeUnits4 :: Word8 -> Word8 -> Word8 -> Word8 -> Builder+utf8CodeUnits4 :: Word8 -> Word8 -> Word8 -> Word8 -> TextBuilder utf8CodeUnits4 = coerce Dev.utf8CodeUnits4 -- | ASCII byte string {-# INLINE asciiByteString #-}-asciiByteString :: ByteString -> Builder+asciiByteString :: ByteString -> TextBuilder asciiByteString = coerce Dev.asciiByteString -- | Strict text {-# INLINE text #-}-text :: Text -> Builder+text :: Text -> TextBuilder text = coerce Dev.text -- | Lazy text {-# INLINE lazyText #-}-lazyText :: TextLazy.Text -> Builder+lazyText :: TextLazy.Text -> TextBuilder lazyText = coerce Dev.lazyText -- | String {-# INLINE string #-}-string :: String -> Builder+string :: String -> TextBuilder string = coerce Dev.string -- | Decimal representation of an integral value {-# INLINEABLE decimal #-}-decimal :: (Integral a) => a -> Builder+decimal :: (Integral a) => a -> TextBuilder decimal = coerce . Dev.decimal -- | Decimal representation of an unsigned integral value {-# INLINEABLE unsignedDecimal #-}-unsignedDecimal :: (Integral a) => a -> Builder+unsignedDecimal :: (Integral a) => a -> TextBuilder unsignedDecimal = coerce . Dev.unsignedDecimal -- | Decimal representation of an integral value with thousands separated by the specified character {-# INLINEABLE thousandSeparatedDecimal #-}-thousandSeparatedDecimal :: (Integral a) => Char -> a -> Builder+thousandSeparatedDecimal :: (Integral a) => Char -> a -> TextBuilder thousandSeparatedDecimal = fmap coerce . Dev.thousandSeparatedDecimal -- | Decimal representation of an unsigned integral value with thousands separated by the specified character {-# INLINEABLE thousandSeparatedUnsignedDecimal #-}-thousandSeparatedUnsignedDecimal :: (Integral a) => Char -> a -> Builder+thousandSeparatedUnsignedDecimal :: (Integral a) => Char -> a -> TextBuilder thousandSeparatedUnsignedDecimal = fmap coerce . Dev.thousandSeparatedUnsignedDecimal -- | Data size in decimal notation over amount of bytes. {-# INLINEABLE dataSizeInBytesInDecimal #-}-dataSizeInBytesInDecimal :: (Integral a) => Char -> a -> Builder+dataSizeInBytesInDecimal :: (Integral a) => Char -> a -> TextBuilder dataSizeInBytesInDecimal = fmap coerce . Dev.dataSizeInBytesInDecimal -- | Unsigned binary number {-# INLINE unsignedBinary #-}-unsignedBinary :: (Integral a) => a -> Builder+unsignedBinary :: (Integral a) => a -> TextBuilder unsignedBinary = coerce . Dev.unsignedBinary -- | Unsigned binary number {-# INLINE unsignedPaddedBinary #-}-unsignedPaddedBinary :: (Integral a, FiniteBits a) => a -> Builder+unsignedPaddedBinary :: (Integral a, FiniteBits a) => a -> TextBuilder unsignedPaddedBinary = coerce . Dev.unsignedPaddedBinary -- | Hexadecimal representation of an integral value {-# INLINE hexadecimal #-}-hexadecimal :: (Integral a) => a -> Builder+hexadecimal :: (Integral a) => a -> TextBuilder hexadecimal = coerce . Dev.hexadecimal -- | Unsigned hexadecimal representation of an integral value {-# INLINE unsignedHexadecimal #-}-unsignedHexadecimal :: (Integral a) => a -> Builder+unsignedHexadecimal :: (Integral a) => a -> TextBuilder unsignedHexadecimal = coerce . Dev.unsignedHexadecimal -- | Decimal digit {-# INLINE decimalDigit #-}-decimalDigit :: (Integral a) => a -> Builder+decimalDigit :: (Integral a) => a -> TextBuilder decimalDigit = coerce . Dev.decimalDigit -- | Hexadecimal digit {-# INLINE hexadecimalDigit #-}-hexadecimalDigit :: (Integral a) => a -> Builder+hexadecimalDigit :: (Integral a) => a -> TextBuilder hexadecimalDigit = coerce . Dev.hexadecimalDigit -- | Intercalate builders {-# INLINE intercalate #-}-intercalate :: (Foldable foldable) => Builder -> foldable Builder -> Builder+intercalate :: (Foldable foldable) => TextBuilder -> foldable TextBuilder -> TextBuilder intercalate a b = coerce (Dev.intercalate (coerce a) (foldr ((:) . coerce) [] b)) -- | Pad a builder from the left side to the specified length with the specified character {-# INLINEABLE padFromLeft #-}-padFromLeft :: Int -> Char -> Builder -> Builder+padFromLeft :: Int -> Char -> TextBuilder -> TextBuilder padFromLeft = coerce Dev.padFromLeft -- | Pad a builder from the right side to the specified length with the specified character {-# INLINEABLE padFromRight #-}-padFromRight :: Int -> Char -> Builder -> Builder+padFromRight :: Int -> Char -> TextBuilder -> TextBuilder padFromRight = coerce Dev.padFromRight -- | -- Time interval in seconds. -- Directly applicable to 'DiffTime' and 'NominalDiffTime'. {-# INLINEABLE intervalInSeconds #-}-intervalInSeconds :: (RealFrac seconds) => seconds -> Builder+intervalInSeconds :: (RealFrac seconds) => seconds -> TextBuilder intervalInSeconds = coerce . Dev.intervalInSeconds -- | Double with a fixed number of decimal places.@@ -256,7 +261,7 @@ -- | Amount of decimals after point. Int -> Double ->- Builder+ TextBuilder fixedDouble = coerce Dev.fixedDouble -- | Double multiplied by 100 with a fixed number of decimal places applied and followed by a percent-sign.@@ -265,10 +270,10 @@ -- | Amount of decimals after point. Int -> Double ->- Builder+ TextBuilder doublePercent = coerce Dev.doublePercent -- | Hexadecimal readable representation of binary data. {-# INLINE hexData #-}-hexData :: ByteString -> Builder+hexData :: ByteString -> TextBuilder hexData = coerce Dev.hexData
text-builder.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: text-builder-version: 0.6.8+version: 0.6.9 category: Text, Builders synopsis: Efficient strict text builder description:@@ -76,7 +76,7 @@ base >=4.11 && <5, bytestring >=0.10 && <0.13, text >=1.2 && <3,- text-builder-dev >=0.3.4.1 && <0.4,+ text-builder-dev >=0.3.9.1 && <0.4, test-suite test import: base