git.iko.soy/typeable/servant
on 98e02ea help sign in
35 lines 1.3 kB history raw
1{-# LANGUAGE PolyKinds #-}
2module Servant.API.MatrixParam where
4-- | Lookup the value associated to the @sym@ matrix string parameter
5-- and try to extract it as a value of type @a@.
6--
7-- Example:
8--
9-- > -- /books;author=<author name>
10-- > type MyApi = "books" :> MatrixParam "author" Text :> Get [Book]
11data MatrixParam sym a
13-- | Lookup the values associated to the @sym@ matrix string parameter
14-- and try to extract it as a value of type @[a]@. This is typically
15-- meant to support matrix string parameters of the form
16-- @param[]=val1;param[]=val2@ and so on. Note that servant doesn't actually
17-- require the @[]@s and will fetch the values just fine with
18-- @param=val1;param=val2@, too.
19--
20-- Example:
21--
22-- > -- /books;authors[]=<author1>;authors[]=<author2>;...
23-- > type MyApi = "books" :> MatrixParams "authors" Text :> Get [Book]
24data MatrixParams sym a
26-- | Lookup a potentially value-less matrix string parameter
27-- with boolean semantics. If the param @sym@ is there without any value,
28-- or if it's there with value "true" or "1", it's interpreted as 'True'.
29-- Otherwise, it's interpreted as 'False'.
30--
31-- Example:
32--
33-- > -- /books;published
34-- > type MyApi = "books" :> MatrixFlag "published" :> Get [Book]
35data MatrixFlag sym