A type-safe string formatting library. Fulfils the need for
string-interpolation or a printf function, without sacrificing Elm's
runtime guarantees.
Example:
import Formatting exposing (..)
greeting =
s "Hello " <> string <> s "!"
print greeting "Kris"
--> "Hello Kris!"Compose two formatters together.
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!"A boilerplate string.
A placeholder for a String argument.
A placeholder for an Int argument.
A placeholder for an Float argument.
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,stringandint, join them together with<>, and when you're done, generate the final printing function withprint.