Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Web.Hyperbole.Route
Synopsis
- class Route a where
- routeUri :: Route a => a -> URI
- class GenRoute f where
- genMatchRoute :: (Generic a, GenRoute (Rep a)) => [Segment] -> Maybe a
- genRoutePath :: (Generic a, GenRoute (Rep a)) => a -> [Segment]
- genRouteRead :: Read x => [Text] -> Maybe (K1 R x a)
- matchRouteRead :: Read a => Path -> Maybe a
- routePathShow :: Show a => a -> Path
- module Web.Hyperbole.Data.URI
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
>>>
routeUri Main
/
>>>
routeUri (User 9)
/user/9
Minimal complete definition
Nothing
Methods
The route to use if attempting to match an empty path
matchRoute :: Path -> Maybe a Source #
Try to match a path to a route
routePath :: a -> Path Source #
Map a route to a path
class GenRoute f 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 # | |
routePathShow :: Show a => a -> Path Source #
module Web.Hyperbole.Data.URI