1
1
mirror of https://github.com/srid/ema.git synced 2024-11-29 09:25:14 +03:00

GenericRouteOpt: add defaults

This commit is contained in:
Sridhar Ratnakumar 2022-07-02 17:16:02 -04:00
parent 505168f783
commit a1c7932c99
2 changed files with 6 additions and 12 deletions

View File

@ -70,8 +70,6 @@ data WithSubModels (subModels :: [Type])
@
data MySubRoutes
instance GenericRouteOpt r MySubRoutes where
type OptModelM r MySubRoutes = 'Nothing
type OptSubModelsM r MySubRoutes = 'Nothing
type
OptSubRoutesM r MySubRoutes =
'Just (GSubRoutes (RDatatypeName r) (RConstructorNames r) (RCode r))
@ -83,20 +81,17 @@ data WithSubModels (subModels :: [Type])
-}
class GenericRouteOpt (r :: Type) (opt :: Type) where
type OptModelM r opt :: Maybe Type
type OptModelM r opt = 'Nothing
type OptSubRoutesM r opt :: Maybe [Type]
type OptSubRoutesM r opt = 'Nothing
type OptSubModelsM r opt :: Maybe [Type]
type OptSubModelsM r opt = 'Nothing
instance GenericRouteOpt r (WithModel t) where
type OptModelM r (WithModel t) = 'Just t
type OptSubRoutesM r (WithModel t) = 'Nothing
type OptSubModelsM r (WithModel t) = 'Nothing
instance GenericRouteOpt r (WithSubRoutes t) where
type OptModelM r (WithSubRoutes _) = 'Nothing
type OptSubRoutesM r (WithSubRoutes t) = 'Just t
type OptSubModelsM r (WithSubRoutes _) = 'Nothing
instance GenericRouteOpt r (WithSubModels t) where
type OptModelM r (WithSubModels t) = 'Nothing
type OptSubRoutesM r (WithSubModels t) = 'Nothing
type OptSubModelsM r (WithSubModels t) = 'Just t
type family OptModel r (opts :: [Type]) :: Type where
@ -146,10 +141,9 @@ instance
, RGeneric r
, mr ~ MultiRoute (SubRoutes r)
, mm ~ MultiModel (SubRoutes r)
, a ~ RouteModel r
, a ~ OptModel r opts
, IsRoute mr
, RouteModel r ~ OptModel r opts
, RouteModel mr ~ NP I mm
, IsRoute mr
, GenericRouteOpts r opts
) =>
IsRoute (GenericRoute r opts)

View File

@ -20,7 +20,7 @@ import Ema.Route.Lib.Multi (MultiRoute)
import GHC.TypeLits (AppendSymbol, Symbol)
#if MIN_VERSION_GLASGOW_HASKELL(9,2,0,0)
import GHC.TypeLits.Extra.Symbol (StripPrefix, ToLower)
import Ema.Route.Lib.File (FileRoute )
import Ema.Route.Lib.File (FileRoute)
import Ema.Route.Lib.Folder (FolderRoute)
#else
import GHC.TypeLits