Safe Haskell | None |
---|---|
Language | Haskell98 |
- type Api m = [(Version, Some1 (Router m))]
- data Router m s where
- data Some1 f where
- route :: Monad s => Resource m s sid mid aid -> Router m s
- compose :: Router m s -> Router s t -> Router m s
- (-/) :: Router m s -> Router s t -> Router m s
- (--/) :: Router m s -> Router s t -> Router m s
- (---/) :: Router m s -> Router s t -> Router m s
- (----/) :: Router m s -> Router s t -> Router m s
- (-----/) :: Router m s -> Router s t -> Router m s
- (------/) :: Router m s -> Router s t -> Router m s
- root :: (Applicative m, Monad m) => Router m m
- data Version = Version {}
- mkVersion :: Int -> Int -> Int -> Version
- latest :: Api m -> Maybe (Version, Some1 (Router m))
- parseVersion :: String -> Maybe Version
- lookupVersion :: String -> Api m -> Maybe (Some1 (Router m))
- lookupVersion' :: Version -> Api m -> Maybe (Some1 (Router m))
- withVersion :: String -> Api m -> r -> (Version -> Some1 (Router m) -> r) -> r
Api data types.
An existential where the second argument has kind (* -> *)
.
Defining routes.
route :: Monad s => Resource m s sid mid aid -> Router m s Source
Convenience constructor constructing a route without any subresource.
compose :: Router m s -> Router s t -> Router m s Source
Add the second router as a subresource to the first.
(-/) :: Router m s -> Router s t -> Router m s infixl 4 Source
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(--/) :: Router m s -> Router s t -> Router m s infixl 5 Source
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(---/) :: Router m s -> Router s t -> Router m s infixl 6 Source
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(----/) :: Router m s -> Router s t -> Router m s infixl 7 Source
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(-----/) :: Router m s -> Router s t -> Router m s infixl 8 Source
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(------/) :: Router m s -> Router s t -> Router m s infixl 9 Source
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
root :: (Applicative m, Monad m) => Router m m Source
An empty router to use as the root for your API.
Api versioning.
An API version has three parts. The first is two are used for API breaking changes, the last for non-API breaking changes.
parseVersion :: String -> Maybe Version Source
lookupVersion :: String -> Api m -> Maybe (Some1 (Router m)) Source
Look up a version in an API. The string can either be a valid
version according to parseVersion
, or "latest".