֓^      !"#$%&' ( ) * + , - . / 0 123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\] Safe-Inferred247For putting values in paths and query string parameters@For getting values from url captures and query string parameters^ ,toText True = "true" toText False = "false"_ UfromText "true" = Just True fromText "false" = Just False fromText _ = Nothing%`abcdefghijklmnopqrstuvwxyz^_{|}~#`abcdefghijklmnopqrstuvwxyz^_{|}~None=K A wrapper around    a.Dan even more informative "your json request body wasn't valid" error=a more informative "you just got the HTTP method wrong" errorthe usual "not found" error2 allows you to implement an API and produce a wai .Example: Mtype MyApi = "books" :> Get [Book] -- GET /books :<|> "books" :> ReqBody Book :> Post Book -- POST /books server :: Server MyApi server = listAllBooks :<|> postBook where listAllBooks = ... postBook book = ... app :: Application app = serve myApi server main :: IO () main = Network.Wai.Handler.Warp.run 8080 app If we get a ), it has precedence over everything else.6This in particular means that if we could get several <s, only the first we encounter would be taken into account. $> mempty = NotFound > > NotFound  x = x > WrongMethod ) InvalidBody = InvalidBody > WrongMethod ) _ = WrongMethod > InvalidBody  _ = InvalidBody  the request, the field  may be modified by url routing        None'=JKM7The contained API (second argument) can be found under  ("/" ++ path)" (path being the first argument).Example: h-- GET /hello/world -- returning a JSON encoded World value type MyApi = "hello" :> "world" :> Get World+Make sure the incoming request starts with "/path"5, strip it and pass the rest of the request path to  sublayout.  None=JKM=Union of two APIs, first takes precedence in case of overlap.Example: qtype MyApi = "books" :> Get [Book] -- GET /books :<|> "books" :> ReqBody Book :> Post Book -- POST /books A server for a  bD first tries to match the request again the route represented by a and if it fails tries b7. You must provide a request handler for each route. type MyApi = "books" :> Get [Book] -- GET /books :<|> "books" :> ReqBody Book :> Post Book -- POST /books server :: Server MyApi server = listAllBooks :<|> postBook where listAllBooks = ... postBook book = ...None '234=JKM;Capture a value from the request path under a certain type a.Example: V -- GET /books/:isbn type MyApi = "books" :> Capture "isbn" Text :> Get Book If you use  in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by the n. This lets servant worry about getting it from the URL and turning it into a value of the type you specify.,You can control how it'll be converted from 2 to your type by simply providing an instance of  for your type.Example: type MyApi = "books" :> Capture "isbn" Text :> Get Book server :: Server MyApi server = getBook where getBook :: Text -> EitherT (Int, String) IO Book getBook isbn = ...None '24=JKM4Extract the given header's value as a value of type a.Example: newtype Referer = Referer Text deriving (Eq, Show, FromText, ToText) -- GET /view-my-referer type MyApi = "view-my-referer" :> Header "from" Referer :> Get Referer  If you use  in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by u. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.All it asks is for a  instance.Example: Qnewtype Referer = Referer Text deriving (Eq, Show, FromText, ToText) -- GET /view-my-referer type MyApi = "view-my-referer" :> Header "Referer" Referer :> Get Referer server :: Server MyApi server = viewReferer where viewReferer :: Referer -> EitherT (Int, String) IO referer viewReferer referer = return referer   None '234=JKM!]Lookup a potentially value-less query string parameter with boolean semantics. If the param sym] is there without any value, or if it's there with value "true" or "1", it's interpreted as ". Otherwise, it's interpreted as .Example: O-- /books?published type MyApi = "books" :> QueryFlag "published" :> Get [Book]"$Lookup the values associated to the symB query string parameter and try to extract it as a value of type [a]K. This is typically meant to support query string parameters of the form param[]=val1&param[]=val2< and so on. Note that servant doesn't actually require the [],s and will fetch the values just fine with param=val1&param=val2, too.Example: v-- /books?authors[]=<author1>&authors[]=<author2>&... type MyApi = "books" :> QueryParams "authors" Text :> Get [Book]##Lookup the value associated to the symB query string parameter and try to extract it as a value of type a.Example: ]-- /books?author=<author name> type MyApi = "books" :> QueryParam "author" Text :> Get [Book]$ If you use ! "published" in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type .Example: !type MyApi = "books" :> QueryFlag "published" :> Get [Book] server :: Server MyApi server = getBooks where getBooks :: Bool -> EitherT (Int, String) IO [Book] getBooks onlyPublished = ...return all books, or only the ones that are already published, depending on the argument...% If you use " "authors" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type [Text].]This lets servant worry about looking up 0 or more values in the query string associated to authors@ and turning each of them into a value of the type you specify.=You can control how the individual values are converted from Text2 to your type by simply providing an instance of  for your type.Example: type MyApi = "books" :> QueryParams "authors" Text :> Get [Book] server :: Server MyApi server = getBooksBy where getBooksBy :: [Text] -> EitherT (Int, String) IO [Book] getBooksBy authors = ...return all books by these authors...& If you use # "author" Text in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of type  Text.This lets servant worry about looking it up in the query string and turning it into a value of the type you specify, enclosed in ?, because it may not be there and servant would then hand you .,You can control how it'll be converted from Text2 to your type by simply providing an instance of  for your type.Example: 2type MyApi = "books" :> QueryParam "author" Text :> Get [Book] server :: Server MyApi server = getBooksBy where getBooksBy :: Maybe Text -> EitherT (Int, String) IO [Book] getBooksBy Nothing = ...return all books... getBooksBy (Just author) = ...return books by the given author...!"#$%&!"##&"%!$!"#$%& None '24=JKM',Extract the request body as a value of type a.Example: K -- POST /books type MyApi = "books" :> ReqBody Book :> Post Book( If you use ' in one of the endpoints for your API, this automatically requires your server-side handler to be a function that takes an argument of the type specified by 'u. This lets servant worry about extracting it from the request and turning it into a value of the type you specify.All it asks is for a  instance.Example: type MyApi = "books" :> ReqBody Book :> Post Book server :: Server MyApi server = postBook where postBook :: Book -> EitherT (Int, String) IO Book postBook book = ...insert into your db...'(''('( None+=KM)<Endpoint for simple GET requests. Serves the result as JSON.Example: "type MyApi = "books" :> Get [Book]*$When implementing the handler for a ) endpoint, just like for  ,   and   , the handler code runs in the EitherT (Int, String) IO monad, where the % represents the status code and the D a message, returned in case of failure. You can quite handily use 1 to quickly fail if some conditions are not met.HIf successfully returning a value, we just require that its type has a a instance and servant takes care of encoding it for you, yielding status code 200 along the way.)*))*)* None+=KM+sEndpoint for POST requests. The type variable represents the type of the response body (not the request body, use  for that).Example:  -- POST /books -- with a JSON encoded Book as the request body -- returning the just-created Book type MyApi = "books" :> ReqBody Book :> Post Book,$When implementing the handler for a + endpoint, just like for  ,   and   , the handler code runs in the EitherT (Int, String) IO monad, where the % represents the status code and the D a message, returned in case of failure. You can quite handily use 1 to quickly fail if some conditions are not met.HIf successfully returning a value, we just require that its type has a a instance and servant takes care of encoding it for you, yielding status code 201 along the way.+,++,+, None+=KM-Combinator for DELETE requests.Example: W -- DELETE /books/:isbn type MyApi = "books" :> Capture "isbn" Text :> Delete.If you have a -U endpoint in your API, the handler for this endpoint is meant to delete a resource.-The code of the handler will, just like for  ,   and   , run in EitherT (Int, String) IO (). The $ represents the status code and the ( a message to be returned. You can use S to painlessly error out if the conditions for a successful deletion are not met.-.--.-. None+=KM/IEndpoint for PUT requests, usually used to update a ressource. The type a2 is the type of the response body that's returned.Example: -- PUT /books/:isbn -- with a Book as request body, returning the updated Book type MyApi = "books" :> Capture "isbn" Text :> ReqBody Book :> Put Book0$When implementing the handler for a / endpoint, just like for  ,   and   , the handler code runs in the EitherT (Int, String) IO monad, where the % represents the status code and the D a message, returned in case of failure. You can quite handily use 1 to quickly fail if some conditions are not met.HIf successfully returning a value, we just require that its type has a a instance and servant takes care of encoding it for you, yielding status code 200 along the way./0//0/0None(2468M4/Finally-tagless encoding for our DSL. Keeping repr' and repr* distinct when writing functions with an ExpSYMN context ensures certain invariants (for instance, that there is only one of :, ;, <, and =9 in a value), but sometimes requires a little more work.IThe sitemap QuasiQuoter.... var: type... becomes a capture.../? var: type becomes a query parameter method ... typ becomes a method returning  typ method ...  typ1 -> typ2. becomes a method with request body of  typ1 and returning  typ2:Comments are allowed, and have the standard Haskell format-- for inline {- ... -} for block123456789:;<=>?@ABCDEFGHIJ123456789:;<=>?@ABCDEFGHI456789:;<=>J?@A132BCDEFGHI1324 56789:;<=>?@ABCDEFGHIJ>None'(2468=JKMO,The 'ValidLinkIn f s' constraint holds when s is an API that contains f, and f is a link.KLMNOP%This function will only typecheck if f is an URI within sQRSTUVWXYZ KLMNOPQRSTUVVUTSRQOPZMNKLYXW KLMNOPQRSTUVWXYZNone)=K[&Endpoint for plugging in your own Wai s. The given Y will get the request as received by the server, potentially with a modified (stripped)  if the  is being routed with .:In addition to just letting you plug in your existing WAI s, this can also be used with x to serve static files stored in a particular directory on your filesystem, or to serve your API's documentation with .\KJust pass the request to the underlying application and serve its response.Example: ^type MyApi = "images" :> Raw server :: Server MyApi server = serveDirectory "/var/www/images"[\[[\[\None]2Serve anything under the specified directory as a [ endpoint. Xtype MyApi = "static" :> Raw server :: Server MyApi server = serveDirectory "/var/www" would capture any request to /static/<something> and look for  <something> under /var/www.kIt will do its best to guess the MIME type for that file, based on the extension, and send an appropriate  Content-Type header if possible.If your goal is to serve HTML, CSS and Javascript files that use the rest of the API as a webapp backend, you will most likely not want the static files to be hidden behind a /static/+ prefix. In that case, remember to put the ]( handler in the last position, because servant* will try to match the handlers in order.]]]]None!"#')+-/IP[]NoneK !"#')+-/123456789:;<=>?@ABCDEFGHIKLMNOPQRSTUV[]  !"#$%&'()*+,-./01234567889:;7<=>7?@ A 7  B  C  D  EFGHIJKLMNOPQRSTUVWXYZ[\]^_`abbcdefghijklmnopqrstuvwxyz{|}~7 servant-0.2ServantServant.Common.TextServant.ServerServant.API.SubServant.API.AlternativeServant.API.CaptureServant.API.HeaderServant.API.QueryParamServant.API.ReqBodyServant.API.GetServant.API.PostServant.API.DeleteServant.API.Put Servant.QQServant.Utils.LinksServant.API.RawServant.Utils.StaticFilesDeletePostPutControl.Monad.Trans.EitherTleftServant.API.RQBodyRQBodyGet:>serveDirectoryserveDocumentation Servant.APIbase Data.ProxyProxyToTexttoTextFromTextfromText HasServerServerrouteRoutingApplication RouteResultRR routeResult RouteMismatch InvalidBody WrongMethodNotFoundserve toApplicationfailWith succeedWith isMismatch$fMonoidRouteResult$fMonoidRouteMismatch $fHasServer:>:<|>$fHasServer:<|>CaptureHeader QueryFlag QueryParams QueryParam$fHasServer:>0$fHasServer:>1ReqBody$fHasServerGet$fHasServerPost$fHasServerDelete$fHasServerPutTyp ReqArgValValExpSYMlitcapturereqBody queryParamconjgetpostputdelete>: parseMethodparseUrlSegmentparseUrlparseTyp parseEntry blockComment inlineCommenteoleolsparseAllsitemap$fExpSYMTypeType VLinkHelpervlhLink ValidLinkInmkLinkIsLinkIsLink'IsLink''IsElemAndOr$fVLinkHelper*Post$fVLinkHelper*Get$fVLinkHelper*:>$fValidLinkInfsRaw$fHasServerRaw $fToTextBool$fFromTextBool runReader $fToTextFloat$fFromTextFloat$fToTextDouble$fFromTextDouble$fToTextInteger$fFromTextInteger$fToTextWord64$fFromTextWord64$fToTextWord32$fFromTextWord32$fToTextWord16$fFromTextWord16 $fToTextWord8$fFromTextWord8 $fToTextWord$fFromTextWord $fToTextInt64$fFromTextInt64 $fToTextInt32$fFromTextInt32 $fToTextInt16$fFromTextInt16 $fToTextInt8$fFromTextInt8 $fToTextInt $fFromTextInt $fToText[] $fFromText[] $fToTextText$fFromTextText Data.EitherEither wai-3.0.2 Network.Wai ApplicationRight Data.MonoidmappendNetwork.Wai.InternalpathInfo text-1.2.0.0Data.Text.InternalTextcapturedghc-prim GHC.TypesTrueFalseBool Data.MaybeMaybeNothing aeson-0.8.0.2Data.Aeson.Types.ClassFromJSONIntGHC.BaseStringToJSON either-4.3.2Control.Monad.Trans.Either