Expand URI templates with Burrito

by Taylor Fausak on

RFC 6570 defines a URI template as “a compact sequence of characters for describing a range of Uniform Resource Identifiers through variable expansion.” Burrito is a Haskell library that lets you parse and expand those templates. Here’s a short example to show how it works:

>>> import Burrito
>>> let Just template = parse "http://user.example/~{name}"
>>> expand [("name", stringValue "fred")] template
>>> expand [("name", stringValue "mark")] template


Two Haskell libraries already exist for working with URI templates. Why did I bother writing Burrito?

  • uri-template was uploaded before the RFC was published. It hasn’t been updated since.

  • uri-templater implements the RFC. Unfortunately it uses a bunch of dependencies and it doesn’t appear to be actively maintained.

These were a problem for me because I use URI templating in my github-release package. I want github-release to be on Stackage, so it needs to build with the latest versions of its dependencies. I could’ve forked either of the above packages and brought them up to date, but the RFC wasn’t too intimidating so I decided to start from scratch.


Turns out the RFC was more complicated than I expected. In order to make sure I got everything right, I ended up with 902 test cases. In fact this is what took the bulk of the time developing the library.

Having these tests give me a high degree of confidence that I’m faithfully implementing the RFC. They also allowed me to easily refactor my code after getting everything to work the first time. Believe me, the first implementation was not pretty to look at.

I would’ve liked to implement some property-based tests for this, but I couldn’t think of any interesting properties to write. If you know of some, please let me know!


I’m surprised that the name “burrito” wasn’t taken on Hackage already. Burritos are commonly used when writing monad tutorials, or at least that’s how the jokes go.

Anyway I chose the name “burrito” because I like to pick project names that have associated emoji: :burrito:. Also “burrito” has all the right letters (U, R, I, and T) in the right order.


If you find yourself needing to expand URI templates in Haskell, please consider using Burrito. I’ve tried hard to make it work correctly and be easy to use. Be sure to open an issue if something can be improved!