Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utility functions to work with text
and `text-format`. Feel
free to add more if you need. Some functions have two versions, `'`
suffix means that function operates on strict Text.
- show :: Buildable a => a -> Text
- show' :: Buildable a => a -> Text
- data FPFormat :: *
- showFloat :: RealFloat a => FPFormat -> Maybe Int -> a -> Text
- showFloat' :: RealFloat a => FPFormat -> Maybe Int -> a -> Text
- showFixedPretty' :: Real a => Int -> a -> Text
- showDecimal :: Integral a => a -> Text
- showDecimal' :: Integral a => a -> Text
- pairF :: (Buildable a, Buildable b) => Format r ((a, b) -> r)
- tripleF :: (Buildable a, Buildable b, Buildable c) => Format r ((a, b, c) -> r)
- listJson :: (Foldable t, Buildable a) => Format r (t a -> r)
- listJsonIndent :: (Foldable t, Buildable a) => Word -> Format r (t a -> r)
- listCsv :: (Foldable t, Buildable a) => Format r (t a -> r)
- mapJson :: (IsList t, Item t ~ (k, v), Buildable k, Buildable v) => Format r (t -> r)
- pairBuilder :: (Buildable a, Buildable b) => (a, b) -> Builder
- tripleBuilder :: (Buildable a, Buildable b, Buildable c) => (a, b, c) -> Builder
- listBuilder :: (Buildable prefix, Buildable delimiter, Buildable suffix, Foldable t, Buildable a) => prefix -> delimiter -> suffix -> t a -> Builder
- listBuilderJSON :: (Foldable t, Buildable a) => t a -> Builder
- listBuilderJSONIndent :: (Foldable t, Buildable a) => Word -> t a -> Builder
- listBuilderCSV :: (Foldable t, Buildable a) => t a -> Builder
- mapBuilder :: (Traversable t, Buildable k, Buildable v) => t (k, v) -> Builder
- mapBuilderJson :: (IsList t, Item t ~ (k, v), Buildable k, Buildable v) => t -> Builder
- format :: Params ps => Format -> ps -> Text
- format' :: Params ps => Format -> ps -> Text
- formatSingle :: Buildable a => Format -> a -> Text
- formatSingle' :: Buildable a => Format -> a -> Text
- buildSingle :: Buildable a => Format -> a -> Builder
- readFractional :: Fractional a => Text -> Either String a
- readDouble :: Text -> Either String Double
- readDecimal :: Integral a => Text -> Either String a
- readUnsignedDecimal :: Integral a => Text -> Either String a
formatting
utilities
Control the rendering of floating point numbers.
showFixedPretty' :: Real a => Int -> a -> Text Source #
Render a floating point number using normal notation, with the given number of decimal places. This function also truncates redundant terminating zeros.
showDecimal :: Integral a => a -> Text Source #
showDecimal' :: Integral a => a -> Text Source #
Formatters
Builders
pairBuilder :: (Buildable a, Buildable b) => (a, b) -> Builder Source #
Prints pair (a, b) like "(a, b)"
tripleBuilder :: (Buildable a, Buildable b, Buildable c) => (a, b, c) -> Builder Source #
Prints triple (a, b, c) like "(a, b, c)"
listBuilder :: (Buildable prefix, Buildable delimiter, Buildable suffix, Foldable t, Buildable a) => prefix -> delimiter -> suffix -> t a -> Builder Source #
Generic list builder. Prints prefix, then values separated by delimiter and finally suffix
listBuilderJSON :: (Foldable t, Buildable a) => t a -> Builder Source #
Prints values in JSON-style (e. g. `[111, ololo, blablabla]`)
listBuilderJSONIndent :: (Foldable t, Buildable a) => Word -> t a -> Builder Source #
Like listBuilderJSON, but prints each value on a new line with indentation
mapBuilder :: (Traversable t, Buildable k, Buildable v) => t (k, v) -> Builder Source #
There is no appropriate type class for map, but all reasonable maps
provide something like assocs
function.
Map may be printed prettier (e. g. using JSON style), it's future task.
Having at least one such function is still good anyway.
text-format
utilities
format :: Params ps => Format -> ps -> Text Source #
Deprecated: Not typesafe. Use formatting library instead
Re-export Data.Text.Format.format for convenience
format' :: Params ps => Format -> ps -> Text Source #
Deprecated: Not typesafe. Use formatting library instead
Version of Data.Text.Format.format which returns strict Text
formatSingle :: Buildable a => Format -> a -> Text Source #
Deprecated: Not typesafe. Use formatting library instead
formatSingle' :: Buildable a => Format -> a -> Text Source #
Deprecated: Not typesafe. Use formatting library instead
String readers
readFractional :: Fractional a => Text -> Either String a Source #
Read fractional number. Returns error (i. e. Left) if there is something else
readDouble :: Text -> Either String Double Source #
Like readFractional, but much more efficient. It may be slightly less accurate