| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Fmt.ByteString
Description
ByteString formatting via Builder.
Synopsis
- type ByteFmt = Fmt Builder
- runByteFmt :: ByteFmt ByteString a -> a
- printf :: ByteFmt (IO ()) a -> a
- cat1With :: Foldable f => ([ByteString] -> ByteString) -> Fmt1 Builder ByteString a -> Fmt1 Builder s (f a)
- hsep :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a)
- vsep :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a)
- hang :: Foldable f => Int -> Fmt1 Builder ByteString a -> Fmt1 Builder s (f a)
- list1 :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a)
- replace1 :: ByteString -> Fmt Builder a a -> Fmt Builder a b -> Fmt Builder a b
- splitWith :: (ByteString -> (ByteString, ByteString)) -> (ByteString -> ByteString -> Fmt Builder a2 a1) -> Fmt Builder a1 b -> Fmt Builder a2 b
- run1 :: Fmt1 Builder ByteString a -> a -> ByteString
- jsonList :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a)
- yamlList :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a)
- jsonMap :: Foldable f => Fmt1 Builder ByteString k -> Fmt1 Builder ByteString v -> Fmt1 Builder s (f (k, v))
- yamlMap :: Foldable f => Fmt1 Builder ByteString k -> Fmt1 Builder ByteString v -> Fmt1 Builder s (f (k, v))
ByteFmt
runByteFmt :: ByteFmt ByteString a -> a Source #
Run a ByteFmt to produce a lazy ByteString.
Combinators
cat1With :: Foldable f => ([ByteString] -> ByteString) -> Fmt1 Builder ByteString a -> Fmt1 Builder s (f a) Source #
Format each value in a foldable and join the results.
hsep :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a) Source #
Format each value with spaces in between.
>>>runByteFmt (hsep (fmt1 byteString)) ["one", "two", "three"]"one two three"
vsep :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a) Source #
Format each value on its own line.
hang :: Foldable f => Int -> Fmt1 Builder ByteString a -> Fmt1 Builder s (f a) Source #
Format each value on its own line, indented by n spaces.
list1 :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a) Source #
Format in square brackets with comma separation.
>>>runByteFmt (list1 (fmt1 byteString)) ["one", "two"]"[one, two]"
Splitting
replace1 :: ByteString -> Fmt Builder a a -> Fmt Builder a b -> Fmt Builder a b Source #
Replace the first occurrence of a search term.
>>>runByteFmt (replace1 "bar" "FOO" (fmt (byteString "foobarbaz")))"fooFOObaz"
splitWith :: (ByteString -> (ByteString, ByteString)) -> (ByteString -> ByteString -> Fmt Builder a2 a1) -> Fmt Builder a1 b -> Fmt Builder a2 b Source #
Split the formatted output using a splitting function, then rejoin with a custom combinator.
Running Fmt1
run1 :: Fmt1 Builder ByteString a -> a -> ByteString Source #
Run a Fmt1 to strict ByteString.
Structured output
jsonList :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a) Source #
Format a foldable as a JSON-style list.
>>>printf (jsonList (fmt1 byteString)) ["one", "two"]["one", "two"]
yamlList :: Foldable f => Fmt1 Builder ByteString a -> Fmt1 Builder s (f a) Source #
Format a foldable as a YAML-style list.
>>>printf (yamlList (fmt1 byteString)) ["one", "two"]- one - two