burrito-1.1.0.2: Parse and render URI templates.

Safe HaskellSafe
LanguageHaskell2010

Burrito.Internal.TH

Synopsis

Documentation

uriTemplate :: QuasiQuoter Source #

This can be used together with the QuasiQuotes language extension to parse a URI template at compile time. This is convenient because it allows you to verify the validity of the template when you compile your file as opposed to when you run it.

>>> :set -XQuasiQuotes
>>> import Burrito
>>> let template = [uriTemplate|http://example/search{?query}|]
>>> let values = [("query", stringValue "chorizo")]
>>> expand values template
"http://example/search?query=chorizo"

Note that you cannot use escape sequences in this quasi-quoter. For example, this is invalid: [uriTemplate|\xa0|]. You can however use percent encoded triples as normal. So this is valid: [uriTemplate|%c2%a0|].