Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype GenericRoute r (opts :: [Type]) = GenericRoute r
- class HasSubRoutes r
- class HasSubRoutes r => HasSubModels r
- data WithModel (r :: Type)
- data WithSubRoutes (subRoutes :: [Type])
- data WithSubModels (subModels :: [Type])
- class GenericRouteOpt (r :: Type) (opt :: Type) where
- type OptModelM r opt :: Maybe Type
- type OptSubRoutesM r opt :: Maybe [Type]
- type OptSubModelsM r opt :: Maybe [Type]
- subModels :: HasSubModels r => RouteModel r -> NP I (MultiModel (SubRoutes r))
- newtype FileRoute (filename :: Symbol) = FileRoute ()
- newtype FolderRoute (prefix :: Symbol) r = FolderRoute r
Generic deriving types
newtype GenericRoute r (opts :: [Type]) Source #
DerivingVia type to generically derive IsRoute
Instances
class HasSubRoutes r Source #
HasSubRoutes is a class of routes with an underlying MultiRoute (and MultiModel) representation.
The idea is that by deriving HasSubRoutes (and HasSubModels), we get IsRoute for free (based on MultiRoute).
TODO: Rename this class, or change the API.
Instances
(GenericRouteOpts r opts, RGeneric r, ValidSubRoutes r (OptSubRoutes r opts)) => HasSubRoutes (GenericRoute r opts :: Type) Source # | |
Defined in Ema.Route.Generic type SubRoutes (GenericRoute r opts) :: [Type] Source # |
class HasSubRoutes r => HasSubModels r Source #
Instances
(VerifyModels (RouteModel (GenericRoute r opts)) (MultiModel (SubRoutes (GenericRoute r opts))) (OptSubModels r opts), VerifyRoutes (RCode r) (SubRoutes (GenericRoute r opts)), GSubModels (RouteModel (GenericRoute r opts)) (MultiModel (OptSubRoutes r opts)) (OptSubModels r opts), HasSubRoutes (GenericRoute r opts), GenericRouteOpts r opts) => HasSubModels (GenericRoute r opts) Source # | |
Defined in Ema.Route.Generic subModels :: RouteModel (GenericRoute r opts) -> NP I (MultiModel (SubRoutes (GenericRoute r opts))) Source # |
data WithModel (r :: Type) Source #
Associate the route with the given model type.
Default: ()
Instances
GenericRouteOpt r (WithModel t) Source # | |
type OptModelM r (WithModel t) Source # | |
Defined in Ema.Route.Generic | |
type OptSubModelsM r (WithModel t) Source # | |
Defined in Ema.Route.Generic | |
type OptSubRoutesM r (WithModel t) Source # | |
Defined in Ema.Route.Generic |
data WithSubRoutes (subRoutes :: [Type]) Source #
Specify isomorphic types to delegate sub-route behaviour. Usually this is identical to the route product type.
The isomorphism is specified by Coercible
.
The default implementation uses FileRoute
for terminal routes, and
FolderRoute
(with constructor prefix stripped) for wrapping sub-routes types.
Instances
GenericRouteOpt r (WithSubRoutes t) Source # | |
Defined in Ema.Route.Generic type OptModelM r (WithSubRoutes t) :: Maybe Type Source # type OptSubRoutesM r (WithSubRoutes t) :: Maybe [Type] Source # type OptSubModelsM r (WithSubRoutes t) :: Maybe [Type] Source # | |
type OptModelM r (WithSubRoutes t) Source # | |
Defined in Ema.Route.Generic | |
type OptSubModelsM r (WithSubRoutes t) Source # | |
Defined in Ema.Route.Generic | |
type OptSubRoutesM r (WithSubRoutes t) Source # | |
Defined in Ema.Route.Generic |
data WithSubModels (subModels :: [Type]) Source #
Specify the Data.Generics.Product.Any.HasAny
selector type for sub models
Note: if the selector is a Symbol
you must wrap it in a Proxy
.
Instances
GenericRouteOpt r (WithSubModels t) Source # | |
Defined in Ema.Route.Generic type OptModelM r (WithSubModels t) :: Maybe Type Source # type OptSubRoutesM r (WithSubModels t) :: Maybe [Type] Source # type OptSubModelsM r (WithSubModels t) :: Maybe [Type] Source # | |
type OptModelM r (WithSubModels t) Source # | |
Defined in Ema.Route.Generic | |
type OptSubModelsM r (WithSubModels t) Source # | |
Defined in Ema.Route.Generic | |
type OptSubRoutesM r (WithSubModels t) Source # | |
Defined in Ema.Route.Generic |
Customizing generic deriving
class GenericRouteOpt (r :: Type) (opt :: Type) Source #
Typeclass to control GenericRoute
behaviour.
The FooM
type enables users to define their type optionally, whose default
is specified in the Foo
type family (further below).
You can define your own options, for example:
data MySubRoutes instance GenericRouteOpt r MySubRoutes where type OptSubRoutesM r MySubRoutes = 'Just (GSubRoutes (RDatatypeName r) (RConstructorNames r) (RCode r))
And use it as:
deriving via (GenericRoute MyRoute '[MySubRoutes])
type OptModelM r opt :: Maybe Type Source #
type OptSubRoutesM r opt :: Maybe [Type] Source #
type OptSubRoutesM r opt = 'Nothing
type OptSubModelsM r opt :: Maybe [Type] Source #
type OptSubModelsM r opt = 'Nothing
Instances
GenericRouteOpt r (WithModel t) Source # | |
GenericRouteOpt r (WithSubModels t) Source # | |
Defined in Ema.Route.Generic type OptModelM r (WithSubModels t) :: Maybe Type Source # type OptSubRoutesM r (WithSubModels t) :: Maybe [Type] Source # type OptSubModelsM r (WithSubModels t) :: Maybe [Type] Source # | |
GenericRouteOpt r (WithSubRoutes t) Source # | |
Defined in Ema.Route.Generic type OptModelM r (WithSubRoutes t) :: Maybe Type Source # type OptSubRoutesM r (WithSubRoutes t) :: Maybe [Type] Source # type OptSubModelsM r (WithSubRoutes t) :: Maybe [Type] Source # |
Handy functions
subModels :: HasSubModels r => RouteModel r -> NP I (MultiModel (SubRoutes r)) Source #
Break the model into a list of sub-models used correspondingly by the sub-routes.
Export these for DerivingVia coercion representations
newtype FileRoute (filename :: Symbol) #
A type-level singleton route, whose encoding is given by the symbol parameter.
FileRoute "foo.html" encodes to "foo.html".
TODO: Can this type be simplified? See https://stackoverflow.com/q/72755053/55246
FileRoute () |
Instances
Generic (FileRoute filename) | |
Show (FileRoute filename) | |
KnownSymbol fn => IsRoute (FileRoute fn) | |
Defined in Ema.Route.Lib.File type RouteModel (FileRoute fn) # routePrism :: RouteModel (FileRoute fn) -> Prism_ FilePath (FileRoute fn) # routeUniverse :: RouteModel (FileRoute fn) -> [FileRoute fn] # | |
Eq (FileRoute filename) | |
Ord (FileRoute filename) | |
Defined in Ema.Route.Lib.File compare :: FileRoute filename -> FileRoute filename -> Ordering # (<) :: FileRoute filename -> FileRoute filename -> Bool # (<=) :: FileRoute filename -> FileRoute filename -> Bool # (>) :: FileRoute filename -> FileRoute filename -> Bool # (>=) :: FileRoute filename -> FileRoute filename -> Bool # max :: FileRoute filename -> FileRoute filename -> FileRoute filename # min :: FileRoute filename -> FileRoute filename -> FileRoute filename # | |
type Rep (FileRoute filename) | |
Defined in Ema.Route.Lib.File | |
type RouteModel (FileRoute fn) | |
Defined in Ema.Route.Lib.File |
newtype FolderRoute (prefix :: Symbol) r #
A route that is prefixed at some URL prefix