kcsongor / Purescript Safe Printf
Licence: bsd-3-clause
Safe printf-like formatting in purescript
Stars: ✭ 34
Programming Languages
purescript
368 projects
purescript-safe-printf
A bare-bones proof of concept implementation of a typesafe printf-like interface where the format string is provided as a type-level string.
This library uses the 0.12 version of the compiler.
Example
format (SProxy :: SProxy "Hi %s! Your favourite number is %d") "Bill" 16
produces the string
"Hi Bill! Your favourite number is 16"
A function of the "right type" is generated from the format string, so that
:t format (SProxy :: SProxy "Hi %s! Your favourite number is %d")
gives
String -> Int -> String
You can also choose to use wildcards if you don't want to repeat yourself:
let formatted = format (SProxy :: _ "Hi %s! You are %d") "Bill" 12
TODO
Currently only "%d" and "%s" are supported, without any other fancy formatting.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].