git-remote-ipfs-0.1.0.0: Git remote helper to store git objects on IPFS

Safe HaskellNone
LanguageHaskell2010

Network.IPFS.Git.RemoteHelper.Format

Synopsis

Documentation

fmt :: Format Text a -> a Source #

fstr :: Format r (String -> r) Source #

ftxt :: Format r (Text -> r) Source #

fint :: Integral a => Format r (a -> r) Source #

fcid :: Format r (CID -> r) Source #

fref :: Format r (Ref hash -> r) Source #

(%) :: Format r a -> Format r' r -> Format r' a infixr 9 #

Concatenate two formatters.

formatter1 % formatter2 is a formatter that accepts arguments for formatter1 and formatter2 and concatenates their results. For example

format1 :: Format r (Text -> r)
format1 = "Person's name is " % text
format2 :: Format r r
format2 = ", "
format3 :: Format r (Int -> r)
format3 = "age is " % hex
myFormat :: Formatter r (Text -> Int -> r)
myFormat = format1 % format2 % format3

Notice how the argument types of format1 and format3 are gathered into the type of myFormat.

(This is actually the composition operator for Format's Category instance, but that is (at present) inconvenient to use with regular Prelude. So this function is provided as a convenience.)

shown :: Show a => Format r (a -> r) #

Output a showable value (instance of Show) by turning it into Text:

>>> format ("Value number " % shown % " is " % shown % ".") 42 False
"Value number 42 is False."

data Format r a #

A formatter. When you construct formatters the first type parameter, r, will remain polymorphic. The second type parameter, a, will change to reflect the types of the data that will be formatted. For example, in

myFormat :: Formatter r (Text -> Int -> r)
myFormat = "Person's name is " % text % ", age is " % hex

the first type parameter remains polymorphic, and the second type parameter is Text -> Int -> r, which indicates that it formats a Text and an Int.

When you run the Format, for example with format, you provide the arguments and they will be formatted into a string.

> format ("Person's name is " % text % ", age is " % hex) "Dave" 54
"Person's name is Dave, age is 36"
Instances
Functor (Format r)

Not particularly useful, but could be.

Instance details

Defined in Formatting.Internal

Methods

fmap :: (a -> b) -> Format r a -> Format r b #

(<$) :: a -> Format r b -> Format r a #

Category Format

The same as (%). At present using Category has an import overhead, but one day it might be imported as standard.

Instance details

Defined in Formatting.Internal

Methods

id :: Format a a #

(.) :: Format b c -> Format a b -> Format a c #

a ~ r => IsString (Format r a)

Useful instance for writing format string. With this you can write Foo instead of now "Foo!".

Instance details

Defined in Formatting.Internal

Methods

fromString :: String -> Format r a #

Semigroup (Format r (a -> r)) 
Instance details

Defined in Formatting.Internal

Methods

(<>) :: Format r (a -> r) -> Format r (a -> r) -> Format r (a -> r) #

sconcat :: NonEmpty (Format r (a -> r)) -> Format r (a -> r) #

stimes :: Integral b => b -> Format r (a -> r) -> Format r (a -> r) #

Monoid (Format r (a -> r))

Useful instance for applying two formatters to the same input argument. For example: format (year <> "/" % month) now will yield "2015/01".

Instance details

Defined in Formatting.Internal

Methods

mempty :: Format r (a -> r) #

mappend :: Format r (a -> r) -> Format r (a -> r) -> Format r (a -> r) #

mconcat :: [Format r (a -> r)] -> Format r (a -> r) #