17 lines
No EOL
16 KiB
HTML
17 lines
No EOL
16 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Servant.QQ</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
|
|
window.onload = function () {pageLoad();setSynopsis("mini_Servant-QQ.html");};
|
|
//]]>
|
|
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Servant-QQ.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">servant-0.2: A family of combinators for defining webservices APIs and serving them</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">Servant.QQ</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>QuasiQuoting utilities for API types.</p><p><code><a href="Servant-QQ.html#v:sitemap">sitemap</a></code> allows you to write your type in a very natural way:</p><pre>[sitemap|
|
|
PUT hello String -> ()
|
|
POST hello/p:Int String -> ()
|
|
GET hello/?name:String Int
|
|
|]
|
|
</pre><p>Will generate:</p><pre> "hello" :> ReqBody String :> Put ()
|
|
:<|> "hello" :> Capture "p" Int :> ReqBody String :> Post ()
|
|
:<|> "hello" :> QueryParam "name" String :> Get Int
|
|
</pre><p>Note the <code>/</code> before a <code>QueryParam</code>!</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">class</span> <a href="#t:ExpSYM">ExpSYM</a> repr' repr | repr -> repr', repr' -> repr <span class="keyword">where</span><ul class="subs"><li><a href="#v:lit">lit</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr' -> repr</li><li><a href="#v:capture">capture</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr -> repr</li><li><a href="#v:reqBody">reqBody</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr -> repr</li><li><a href="#v:queryParam">queryParam</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr -> repr</li><li><a href="#v:conj">conj</a> :: repr' -> repr -> repr</li><li><a href="#v:get">get</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr</li><li><a href="#v:post">post</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr</li><li><a href="#v:put">put</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr</li><li><a href="#v:delete">delete</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr</li></ul></li><li class="src short"><a href="#v:-62-:">(>:)</a> :: <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a></li><li class="src short"><a href="#v:parseMethod">parseMethod</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr' repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (<a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr)</li><li class="src short"><a href="#v:parseUrlSegment">parseUrlSegment</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (repr -> repr)</li><li class="src short"><a href="#v:parseUrl">parseUrl</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (repr -> repr)</li><li class="src short"><span class="keyword">data</span> <a href="#t:Typ">Typ</a><ul class="subs"><li>= <a href="#v:Val">Val</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a></li><li>| <a href="#v:ReqArgVal">ReqArgVal</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a></li></ul></li><li class="src short"><a href="#v:parseTyp">parseTyp</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> <a href="Servant-QQ.html#t:Typ">Typ</a></li><li class="src short"><a href="#v:parseEntry">parseEntry</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> repr</li><li class="src short"><a href="#v:blockComment">blockComment</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> ()</li><li class="src short"><a href="#v:inlineComment">inlineComment</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> ()</li><li class="src short"><a href="#v:eol">eol</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:eols">eols</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> ()</li><li class="src short"><a href="#v:parseAll">parseAll</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a></li><li class="src short"><a href="#v:sitemap">sitemap</a> :: <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:ExpSYM" class="def">ExpSYM</a> repr' repr | repr -> repr', repr' -> repr <span class="keyword">where</span> <a href="src/Servant-QQ.html#ExpSYM" class="link">Source</a></p><div class="doc"><p>Finally-tagless encoding for our DSL.
|
|
Keeping <code>repr'</code> and <code>repr</code> distinct when writing functions with an
|
|
<code>ExpSYM</code> context ensures certain invariants (for instance, that there is
|
|
only one of <code><a href="Servant-QQ.html#v:get">get</a></code>, <code><a href="Servant-QQ.html#v:post">post</a></code>, <code><a href="Servant-QQ.html#v:put">put</a></code>, and <code><a href="Servant-QQ.html#v:delete">delete</a></code> in a value), but
|
|
sometimes requires a little more work.</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:lit" class="def">lit</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr' -> repr <a href="src/Servant-QQ.html#lit" class="link">Source</a></p><p class="src"><a name="v:capture" class="def">capture</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr -> repr <a href="src/Servant-QQ.html#capture" class="link">Source</a></p><p class="src"><a name="v:reqBody" class="def">reqBody</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr -> repr <a href="src/Servant-QQ.html#reqBody" class="link">Source</a></p><p class="src"><a name="v:queryParam" class="def">queryParam</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr -> repr <a href="src/Servant-QQ.html#queryParam" class="link">Source</a></p><p class="src"><a name="v:conj" class="def">conj</a> :: repr' -> repr -> repr <a href="src/Servant-QQ.html#conj" class="link">Source</a></p><p class="src"><a name="v:get" class="def">get</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr <a href="src/Servant-QQ.html#get" class="link">Source</a></p><p class="src"><a name="v:post" class="def">post</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr <a href="src/Servant-QQ.html#post" class="link">Source</a></p><p class="src"><a name="v:put" class="def">put</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr <a href="src/Servant-QQ.html#put" class="link">Source</a></p><p class="src"><a name="v:delete" class="def">delete</a> :: <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr <a href="src/Servant-QQ.html#delete" class="link">Source</a></p></div><div class="subs instances"><p id="control.i:ExpSYM" class="caption collapser" onclick="toggleSection('i:ExpSYM')">Instances</p><div id="section.i:ExpSYM" class="show"><table><tr><td class="src"><a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:-62-:" class="def">(>:)</a> :: <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> <span class="fixity">infixr 6</span><span class="rightedge"></span> <a href="src/Servant-QQ.html#%3E%3A" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:parseMethod" class="def">parseMethod</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr' repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (<a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -> repr) <a href="src/Servant-QQ.html#parseMethod" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:parseUrlSegment" class="def">parseUrlSegment</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (repr -> repr) <a href="src/Servant-QQ.html#parseUrlSegment" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:parseUrl" class="def">parseUrl</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (repr -> repr) <a href="src/Servant-QQ.html#parseUrl" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Typ" class="def">Typ</a> <a href="src/Servant-QQ.html#Typ" class="link">Source</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Val" class="def">Val</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:ReqArgVal" class="def">ReqArgVal</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a></td><td class="doc empty"> </td></tr></table></div></div><div class="top"><p class="src"><a name="v:parseTyp" class="def">parseTyp</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> <a href="Servant-QQ.html#t:Typ">Typ</a> <a href="src/Servant-QQ.html#parseTyp" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:parseEntry" class="def">parseEntry</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr => <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> repr <a href="src/Servant-QQ.html#parseEntry" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:blockComment" class="def">blockComment</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> () <a href="src/Servant-QQ.html#blockComment" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:inlineComment" class="def">inlineComment</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> () <a href="src/Servant-QQ.html#inlineComment" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:eol" class="def">eol</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> <a href="src/Servant-QQ.html#eol" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:eols" class="def">eols</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> () <a href="src/Servant-QQ.html#eols" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:parseAll" class="def">parseAll</a> :: <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> <a href="src/Servant-QQ.html#parseAll" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:sitemap" class="def">sitemap</a> :: <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a> <a href="src/Servant-QQ.html#sitemap" class="link">Source</a></p><div class="doc"><p>The sitemap QuasiQuoter.</p><ul><li><code>...<em><a href="var">var</a>:<a href="type">type</a></em>...</code> becomes a capture</li><li><code>.../?<a href="var">var</a>:<a href="type">type</a></code> becomes a query parameter</li><li><code><a href="method">method</a> ... <a href="typ">typ</a></code> becomes a method returning <code><a href="typ">typ</a></code></li><li><code><a href="method">method</a> ... <a href="typ1">typ1</a> -> <a href="typ2">typ2</a></code> becomes a method with request
|
|
body of <code><a href="typ1">typ1</a></code> and returning <code><a href="typ2">typ2</a></code></li></ul><p>Comments are allowed, and have the standard Haskell format</p><ul><li><code>--</code> for inline</li><li><code>{- ... -}</code> for block</li></ul></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.15.0</p></div></body></html> |