krisajenkins/formatting/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Formatting

A type-safe string formatting library. Fulfils the need for string-interpolation or a printf function, without sacrificing Elm's runtime guarantees.

type Format r a

A string formatter. This type holds all the information we need to create a formatting function, wrapped up in a way that makes it easy to compose.

Build one of these up with primitives like s, string and int, join them together with <>, and when you're done, generate the final printing function with print.

(<>) : Format b a -> Format c b -> Format c a

Compose two formatters together.

print : Format String a -> a

Turn your formatter into a function that's just waiting for its arguments.

For example:

order =
    let
        format = s "FREE: " <> int <> s " x " <> string  <> s "!"
    in
        print format 2 "Ice Cream"


--> "FREE: 2 x Ice Cream!"
s : String -> Format a a

A boilerplate string.

string : Format r (String -> r)

A placeholder for a String argument.

int : Format r (Int -> r)

A placeholder for an Int argument.

float : Format r (Float -> r)

A placeholder for an Float argument.