Safe Haskell | None |
---|---|
Language | Haskell2010 |
QuasiQuoting utilities for API types.
sitemap
allows you to write your type in a very natural way:
[sitemap| PUT hello String -> () POST hello/p:Int String -> () GET hello/?name:String Int |]
Will generate:
"hello" :> ReqBody String :> Put () :<|> "hello" :> Capture "p" Int :> ReqBody String :> Post () :<|> "hello" :> QueryParam "name" String :> Get Int
Note the /
before a QueryParam
!
- class ExpSYM repr' repr | repr -> repr', repr' -> repr where
- (>:) :: Type -> Type -> Type
- parseMethod :: ExpSYM repr' repr => Parser (String -> repr)
- parseUrlSegment :: ExpSYM repr repr => Parser (repr -> repr)
- parseUrl :: ExpSYM repr repr => Parser (repr -> repr)
- data Typ
- parseTyp :: Parser Typ
- parseEntry :: ExpSYM repr repr => Parser repr
- blockComment :: Parser ()
- inlineComment :: Parser ()
- eol :: Parser String
- eols :: Parser ()
- parseAll :: Parser Type
- sitemap :: QuasiQuoter
Documentation
class ExpSYM repr' repr | repr -> repr', repr' -> repr where Source
Finally-tagless encoding for our DSL.
Keeping repr'
and repr
distinct when writing functions with an
ExpSYM
context ensures certain invariants (for instance, that there is
only one of get
, post
, put
, and delete
in a value), but
sometimes requires a little more work.
parseMethod :: ExpSYM repr' repr => Parser (String -> repr) Source
parseUrlSegment :: ExpSYM repr repr => Parser (repr -> repr) Source
parseEntry :: ExpSYM repr repr => Parser repr Source
blockComment :: Parser () Source
inlineComment :: Parser () Source
The sitemap QuasiQuoter.
...var:type...
becomes a capture.../?var:type
becomes a query parametermethod ... typ
becomes a method returningtyp
method ... typ1 -> typ2
becomes a method with request body oftyp1
and returningtyp2
Comments are allowed, and have the standard Haskell format
--
for inline{- ... -}
for block