Sometime in 2007 I wrote a small Haskell library for simple string substitution: given a string with placeholders, e.g. “Hi, $name!”, and a context that maps placeholders to values you can easily substitute the placeholders for the values.
After receiving some user feedback I’ve now updated the library and released version 0.2 on Hackage. Here's what's new in this release:
- The String type has been replaced with the new Text type from the text library.
- The API has been generalized to support more sophisticated error reporting, using an applicative functor interface.
- The I/O API has been removed; use the I/O API in the text library API instead.
- The context that maps placeholder to values can now be any function from keys to values, instead of just a Map.
Here’s a usage example: