fmt-0.0.0.4: A new formatting library

Safe HaskellNone
LanguageHaskell2010

Fmt.Internal

Contents

Description

A module providing access to internals (in case you really need them). Can change at any time, though probably won't.

Synopsis

Classes

class FromBuilder a where #

Minimal complete definition

fromBuilder

Methods

fromBuilder :: Builder -> a #

Convert a Builder to something else.

Instances

FromBuilder Text # 

Methods

fromBuilder :: Builder -> Text #

FromBuilder Text # 

Methods

fromBuilder :: Builder -> Text #

FromBuilder Builder # 
(~) * a Char => FromBuilder [a] # 

Methods

fromBuilder :: Builder -> [a] #

(~) * a () => FromBuilder (IO a) # 

Methods

fromBuilder :: Builder -> IO a #

class FormatAsHex a where #

Minimal complete definition

hexF

Methods

hexF :: a -> Builder #

Format a number or bytestring as hex:

>>> hexF 3635
"e33"
>>> hexF ("\0\50\63\80" :: BS.ByteString)
"00323f50"

Instances

class FormatAsBase64 a where #

Minimal complete definition

base64F, base64UrlF

Methods

base64F :: a -> Builder #

Convert a bytestring to base64:

>>> base64F ("\0\50\63\80" :: BS.ByteString)
"ADI/UA=="

base64UrlF :: a -> Builder #

Convert a bytestring to base64url (a variant of base64 which omits / and thus can be used in URLs):

>>> base64UrlF ("\0\50\63\80" :: BS.ByteString)
"ADI_UA=="

class TupleF a where #

Minimal complete definition

tupleF

Methods

tupleF :: a -> Builder #

Format a tuple (of up to 8 elements):

>>> tupleF (1,2,"hi")
"(1, 2, hi)"

If any of the elements takes several lines, an alternate format is used:

>>> fmt $ tupleF ("test","foo\nbar","more test")
( test
,
  foo
  bar
,
  more test )

Classes used for genericF

class GBuildable f where #

Minimal complete definition

gbuild

Methods

gbuild :: f a -> Builder #

class GetFields f where #

Minimal complete definition

getFields

Methods

getFields :: f a -> [(String, Builder)] #

Get fields, together with their names if available

class Buildable' a where #

A more powerful Buildable used for genericF. Can build functions, tuples, lists, maps, etc., as well as combinations thereof.

Minimal complete definition

build'

Methods

build' :: a -> Builder #

Helpers

groupInt :: (Buildable a, Integral a) => Int -> Char -> a -> Builder #

atBase :: Integral a => Int -> a -> String #

showSigned' :: Real a => (a -> ShowS) -> a -> ShowS #

indent' :: Int -> Text -> Builder -> Builder #

Add a prefix to the first line, and indent all lines but the first one.

The output will always end with a newline, even when the input doesn't.