typist: Typelevel printf

[ library, mit, text ] [ Propose Tags ]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],
Change log CHANGELOG.md
Dependencies base (>=4.16 && <4.20), text, text-show [details]
License MIT
Author Danil Berestov
Maintainer goosedb@yandex.ru
Category Text
Home page https://github.com/goosedb/typist
Uploaded by goosedb at 2024-04-30T14:12:42Z
Distributions NixOS:
Downloads 45 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for typist-

[back to package description]


Typist is a library for interpolation. It uses type-level strings (Symbols) for template. It uses UnconsSynbol type family which is added in GHC-9.2, so you need GHC version 9.2 or higher to use it.

Core functionality is in Typist.Internal.Format:

  • Type family Format which transforms Symbol to function which renders final string
  • Arg newtype over Text.Lazy.Builder which carries name of parameter and it's position in string on type-level (for perfomance goods)
  • Type class Interpolate which renders final string on term level

An example of wrapping it (and also ready to use interface) is located in Typist.TextShow:

  • Unquoted newtype for interpolation strings without \"
  • #= set operator Example (more examples can be found in test/Test):
question = fmt @"Hello, #{name}, do you like #{dish}?" $ 
  (#name #= Unquoted "Mike") .
  (#dish #= Unquoted "pasta")

Performance is comparable with bare concatenation with <>. Benches can be found at test/Bench


Alt text


Alt text


Alt text

To run benchmark use

$ cabal bench --benchmark-options '--svg results_cpu.svg'