servant/Servant-QQ.html

17 lines
16 KiB
HTML
Raw Permalink Normal View History

<!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 -&gt; ()
POST hello/p:Int String -&gt; ()
GET hello/?name:String Int
|]
</pre><p>Will generate:</p><pre> &quot;hello&quot; :&gt; ReqBody String :&gt; Put ()
:&lt;|&gt; &quot;hello&quot; :&gt; Capture &quot;p&quot; Int :&gt; ReqBody String :&gt; Post ()
:&lt;|&gt; &quot;hello&quot; :&gt; QueryParam &quot;name&quot; String :&gt; 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 -&gt; repr', repr' -&gt; 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> -&gt; repr' -&gt; 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> -&gt; <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -&gt; repr -&gt; 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> -&gt; repr -&gt; 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> -&gt; <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -&gt; repr -&gt; repr</li><li><a href="#v:conj">conj</a> :: repr' -&gt; repr -&gt; 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> -&gt; 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> -&gt; 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> -&gt; 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> -&gt; repr</li></ul></li><li class="src short"><a href="#v:-62-:">(&gt;:)</a> :: <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -&gt; <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -&gt; <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 =&gt; <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> -&gt; repr)</li><li class="src short"><a href="#v:parseUrlSegment">parseUrlSegment</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr =&gt; <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (repr -&gt; repr)</li><li class="src short"><a href="#v:parseUrl">parseUrl</a> :: <a href="Servant-QQ.html#t:ExpSYM">ExpSYM</a> repr repr =&gt; <a href="https://hackage.haskell.org/package/parsec-3.1.7/docs/Text-Parsec-String.html#t:Parser">Parser</a> (repr -&gt; 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="Ser
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> -&gt; repr' -&gt; 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> -&gt; <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -&gt; repr -&gt; 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> -&gt; repr -&gt; 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> -&gt; <a href="https://hackage.haskell.org/package/base-4.7.0.1/docs/Data-String.html#t:String">String</a> -&gt; repr -&gt; 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' -&gt; repr -&gt; 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> -&gt; 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> -&gt; 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> -&gt; 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> -&gt; 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">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:-62-:" class="def">(&gt;:)</a> :: <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -&gt; <a href="https://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -&gt; <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 =&gt; <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> -&gt; 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=
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>