| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Airship.Route
- data Route
- data RoutingSpec m a
- data RouteLeaf m
- data Trie a :: * -> *
- root :: Route
- var :: Text -> Route
- star :: Route
- (</>) :: Route -> Route -> Route
- (#>) :: MonadWriter [(ByteString, RouteLeaf a)] m => Route -> Resource a -> m ()
- (#>=) :: MonadWriter [(ByteString, RouteLeaf a)] m => Route -> m (Resource a) -> m ()
- runRouter :: RoutingSpec m a -> Trie (RouteLeaf m)
Documentation
data RoutingSpec m a Source #
Represents a fully-specified set of routes that map paths (represented as Routes) to Resources. RoutingSpecs are declared with do-notation, to wit:
myRoutes :: RoutingSpec IO ()
myRoutes = do
root #> myRootResource
"blog" </> var "date" </> var "post" #> blogPostResource
"about" #> aboutResource
"anything" </> star #> wildcardResource
Instances
| Monad (RoutingSpec m) Source # | |
| Functor (RoutingSpec m) Source # | |
| Applicative (RoutingSpec m) Source # | |
| MonadWriter [(ByteString, RouteLeaf m)] (RoutingSpec m) Source # | |
Instances
| MonadWriter [(ByteString, RouteLeaf m)] (RoutingSpec m) Source # | |
A map from ByteStrings to a. For all the generic functions,
note that tries are strict in the Maybe but not in a.
The Monad instance is strange. If a key k1 is a prefix of
other keys, then results from binding the value at k1 will
override values from longer keys when they collide. If this is
useful for anything, or if there's a more sensible instance, I'd
be curious to know.
Represents the root resource (/). This should usually be the first path declared in a RoutingSpec.
Captures a wildcard route. For example,
"emcees" </> star
will match /emcees, /emcees/biggie, /emcees/earl/vince, and so on and so forth.
(#>) :: MonadWriter [(ByteString, RouteLeaf a)] m => Route -> Resource a -> m () Source #
(#>=) :: MonadWriter [(ByteString, RouteLeaf a)] m => Route -> m (Resource a) -> m () Source #
runRouter :: RoutingSpec m a -> Trie (RouteLeaf m) Source #
Turns the list of routes in a RoutingSpec into a Trie for efficient
routing