Safe Haskell | None |
---|---|
Language | Haskell2010 |
Type safe internal links.
Provides the function mkLink
:
type API = Proxy ("hello" :> Get Int :| "bye" :> QueryParam "name" String :> Post Bool) api :: API api = proxy link1 :: Proxy ("hello" :> Get Int) link1 = proxy link2 :: Proxy ("hello" :> Delete) link2 = proxy mkLink link1 API -- typechecks, returns 'Link "/hello"' mkLink link2 API -- doesn't typecheck
That is, mkLink
takes two arguments, a link proxy and a sitemap, and
returns a Link
, but only typechecks if the link proxy is a valid link,
and part of the sitemap.
N.B.: mkLink
assumes a capture matches any string (without slashes).
Documentation
class ValidLinkIn f s where Source
The 'ValidLinkIn f s' constraint holds when s
is an API that
contains f
, and f
is a link.
((~) Bool (IsElem f s) True, (~) Bool (IsLink f) True, VLinkHelper * f) => ValidLinkIn f s |
class VLinkHelper f where Source
VLinkHelper * (Get x) | |
VLinkHelper * (Post x) | |
(KnownSymbol s, VLinkHelper * e) => VLinkHelper * ((:>) Symbol s e) |