ema-generics-0.10.0.0: Static site generator library with hot reload
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ema.Route.Generic

Synopsis

Generic deriving types

newtype GenericRoute r (opts :: [Type]) Source #

DerivingVia type to generically derive IsRoute

Constructors

GenericRoute r 

Instances

Instances details
(GenericRouteOpts r opts, RGeneric r, ValidSubRoutes r (OptSubRoutes r opts)) => HasSubRoutes (GenericRoute r opts :: Type) Source # 
Instance details

Defined in Ema.Route.Generic

Associated Types

type SubRoutes (GenericRoute r opts) :: [Type] Source #

Generic (GenericRoute r opts) Source # 
Instance details

Defined in Ema.Route.Generic

Associated Types

type Rep (GenericRoute r opts) :: Type -> Type #

Methods

from :: GenericRoute r opts -> Rep (GenericRoute r opts) x #

to :: Rep (GenericRoute r opts) x -> GenericRoute r opts #

(VerifyRoutes (RCode r) (SubRoutes (GenericRoute r opts)), HasSubRoutes r, HasSubModels r, ValidSubRoutes r (SubRoutes r), RGeneric r, mr ~ MultiRoute (SubRoutes r), mm ~ MultiModel (SubRoutes r), RouteModel r ~ OptModel r opts, RouteModel mr ~ NP I mm, IsRoute mr, GenericRouteOpts r opts) => IsRoute (GenericRoute r opts) Source # 
Instance details

Defined in Ema.Route.Generic

Associated Types

type RouteModel (GenericRoute r opts) #

(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 # 
Instance details

Defined in Ema.Route.Generic

type SubRoutes (GenericRoute r opts :: Type) Source # 
Instance details

Defined in Ema.Route.Generic

type SubRoutes (GenericRoute r opts :: Type)
type Rep (GenericRoute r opts) Source # 
Instance details

Defined in Ema.Route.Generic

type Rep (GenericRoute r opts) = D1 ('MetaData "GenericRoute" "Ema.Route.Generic" "ema-generics-0.10.0.0-HhlnNmEuaab2xzK9aLaU3c" 'True) (C1 ('MetaCons "GenericRoute" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 r)))
type RouteModel (GenericRoute r opts) Source # 
Instance details

Defined in Ema.Route.Generic

type RouteModel (GenericRoute r opts)

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

Instances details
(GenericRouteOpts r opts, RGeneric r, ValidSubRoutes r (OptSubRoutes r opts)) => HasSubRoutes (GenericRoute r opts :: Type) Source # 
Instance details

Defined in Ema.Route.Generic

Associated Types

type SubRoutes (GenericRoute r opts) :: [Type] Source #

class HasSubRoutes r => HasSubModels r Source #

Minimal complete definition

subModels

Instances

Instances details
(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 # 
Instance details

Defined in Ema.Route.Generic

data WithModel (r :: Type) Source #

Associate the route with the given model type.

Default: ()

Instances

Instances details
GenericRouteOpt r (WithModel t) Source # 
Instance details

Defined in Ema.Route.Generic

Associated Types

type OptModelM r (WithModel t) :: Maybe Type Source #

type OptSubRoutesM r (WithModel t) :: Maybe [Type] Source #

type OptSubModelsM r (WithModel t) :: Maybe [Type] Source #

type OptModelM r (WithModel t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptModelM r (WithModel t) = 'Just t
type OptSubModelsM r (WithModel t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptSubRoutesM r (WithModel t) Source # 
Instance details

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

Instances details
GenericRouteOpt r (WithSubRoutes t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptModelM r (WithSubRoutes t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptSubModelsM r (WithSubRoutes t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptSubRoutesM r (WithSubRoutes t) Source # 
Instance details

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

Instances details
GenericRouteOpt r (WithSubModels t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptModelM r (WithSubModels t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptSubModelsM r (WithSubModels t) Source # 
Instance details

Defined in Ema.Route.Generic

type OptSubRoutesM r (WithSubModels t) Source # 
Instance details

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])

Associated Types

type OptModelM r opt :: Maybe Type Source #

type OptModelM r opt = 'Nothing

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

Instances details
GenericRouteOpt r (WithModel t) Source # 
Instance details

Defined in Ema.Route.Generic

Associated Types

type OptModelM r (WithModel t) :: Maybe Type Source #

type OptSubRoutesM r (WithModel t) :: Maybe [Type] Source #

type OptSubModelsM r (WithModel t) :: Maybe [Type] Source #

GenericRouteOpt r (WithSubModels t) Source # 
Instance details

Defined in Ema.Route.Generic

GenericRouteOpt r (WithSubRoutes t) Source # 
Instance details

Defined in Ema.Route.Generic

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

Constructors

FileRoute () 

Instances

Instances details
Generic (FileRoute filename) 
Instance details

Defined in Ema.Route.Lib.File

Associated Types

type Rep (FileRoute filename) :: Type -> Type #

Methods

from :: FileRoute filename -> Rep (FileRoute filename) x #

to :: Rep (FileRoute filename) x -> FileRoute filename #

Show (FileRoute filename) 
Instance details

Defined in Ema.Route.Lib.File

Methods

showsPrec :: Int -> FileRoute filename -> ShowS #

show :: FileRoute filename -> String #

showList :: [FileRoute filename] -> ShowS #

KnownSymbol fn => IsRoute (FileRoute fn) 
Instance details

Defined in Ema.Route.Lib.File

Associated Types

type RouteModel (FileRoute fn) #

Eq (FileRoute filename) 
Instance details

Defined in Ema.Route.Lib.File

Methods

(==) :: FileRoute filename -> FileRoute filename -> Bool #

(/=) :: FileRoute filename -> FileRoute filename -> Bool #

Ord (FileRoute filename) 
Instance details

Defined in Ema.Route.Lib.File

Methods

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) 
Instance details

Defined in Ema.Route.Lib.File

type Rep (FileRoute filename) = D1 ('MetaData "FileRoute" "Ema.Route.Lib.File" "ema-0.10.0.0-IvDsUicoMaZ9ZiKA06zERq" 'True) (C1 ('MetaCons "FileRoute" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ())))
type RouteModel (FileRoute fn) 
Instance details

Defined in Ema.Route.Lib.File

type RouteModel (FileRoute fn) = ()

newtype FolderRoute (prefix :: Symbol) r #

A route that is prefixed at some URL prefix

Constructors

FolderRoute r 

Instances

Instances details
Generic r => Generic (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

Associated Types

type Rep (FolderRoute prefix r) :: Type -> Type #

Methods

from :: FolderRoute prefix r -> Rep (FolderRoute prefix r) x #

to :: Rep (FolderRoute prefix r) x -> FolderRoute prefix r #

(Show r, KnownSymbol prefix) => Show (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

Methods

showsPrec :: Int -> FolderRoute prefix r -> ShowS #

show :: FolderRoute prefix r -> String #

showList :: [FolderRoute prefix r] -> ShowS #

(IsRoute r, KnownSymbol prefix) => IsRoute (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

Associated Types

type RouteModel (FolderRoute prefix r) #

Methods

routePrism :: RouteModel (FolderRoute prefix r) -> Prism_ FilePath (FolderRoute prefix r) #

routeUniverse :: RouteModel (FolderRoute prefix r) -> [FolderRoute prefix r] #

(EmaStaticSite r, KnownSymbol prefix) => EmaSite (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

Associated Types

type SiteArg (FolderRoute prefix r) #

type SiteOutput (FolderRoute prefix r) #

Methods

siteInput :: (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> SiteArg (FolderRoute prefix r) -> m (Dynamic m (RouteModel (FolderRoute prefix r))) #

siteOutput :: (MonadIO m, MonadLoggerIO m) => Prism' FilePath (FolderRoute prefix r) -> RouteModel (FolderRoute prefix r) -> FolderRoute prefix r -> m (SiteOutput (FolderRoute prefix r)) #

Eq r => Eq (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

Methods

(==) :: FolderRoute prefix r -> FolderRoute prefix r -> Bool #

(/=) :: FolderRoute prefix r -> FolderRoute prefix r -> Bool #

Ord r => Ord (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

Methods

compare :: FolderRoute prefix r -> FolderRoute prefix r -> Ordering #

(<) :: FolderRoute prefix r -> FolderRoute prefix r -> Bool #

(<=) :: FolderRoute prefix r -> FolderRoute prefix r -> Bool #

(>) :: FolderRoute prefix r -> FolderRoute prefix r -> Bool #

(>=) :: FolderRoute prefix r -> FolderRoute prefix r -> Bool #

max :: FolderRoute prefix r -> FolderRoute prefix r -> FolderRoute prefix r #

min :: FolderRoute prefix r -> FolderRoute prefix r -> FolderRoute prefix r #

type Rep (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

type Rep (FolderRoute prefix r) = Rep r
type RouteModel (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

type RouteModel (FolderRoute prefix r) = RouteModel r
type SiteArg (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder

type SiteArg (FolderRoute prefix r) = SiteArg r
type SiteOutput (FolderRoute prefix r) 
Instance details

Defined in Ema.Route.Lib.Folder