Safe Haskell | None |
---|---|
Language | GHC2021 |
Documentation
Derive this class to use a sum type as a route. Constructors and Selectors map intuitively to url patterns
data AppRoute
= Main
| Messages
| User UserId
deriving (Eq, Generic)
instance Route
AppRoute where
baseRoute = Just Main
>>>
routeUrl Main
/
>>>
routeUrl (User 9)
/user/9
Nothing
The route to use if attempting to match on empty segments
matchRoute :: [Segment] -> Maybe a Source #
Try to match segments to a route
routePath :: a -> [Segment] Source #
Map a route to segments
findRoute :: Route a => [Segment] -> Maybe a Source #
Try to match a route, use defRoute
if it's empty
class GenRoute (f :: k -> Type) where Source #
Automatically derive Route
Instances
GenRoute (U1 :: k -> Type) Source # | |
(GenRoute a, GenRoute b) => GenRoute (a :*: b :: k -> Type) Source # | |
(GenRoute a, GenRoute b) => GenRoute (a :+: b :: k -> Type) Source # | |
Route sub => GenRoute (K1 R sub :: k -> Type) Source # | |
(Constructor c, GenRoute f) => GenRoute (M1 C c f :: k -> Type) Source # | |
GenRoute f => GenRoute (M1 D c f :: k -> Type) Source # | |
GenRoute f => GenRoute (M1 S c f :: k -> Type) Source # | |