CurryInfo: spicey-4.2.0 / Spicey.EntityRoutesGeneration.controllerInstDecl

definition: Info
 
controllerInstDecl :: String -> Entity -> CInstanceDecl
controllerInstDecl erdname (Entity entityName _) =
  simpleInstanceDecl (spiceyModule,"EntityController")
    entityType
    [stFunc (spiceyModule,"controllerOnKey") 1 Private
       (stringType ~> (entityType ~> controllerType) ~> controllerType)
       [simpleRule [CPVar (2,"s")]
                   (applyF (spiceyModule,"applyControllerOn")
                           [readKey, getEntityOp])],
     stFunc (spiceyModule,"entityRoute") 2 Private
       (stringType ~> entityType ~> stringType)
       [simpleRule [CPVar rvar, CPVar entvar]
          (applyF (pre "concat")
             [list2ac
                [string2ac $ '?' : entityName ++ "/",
                 CVar rvar,
                 string2ac "/",
                 applyF (model erdname, "show" ++ entityName ++ "Key")
                        [CVar entvar]]])]]
 where
  entityType  = baseType (model erdname, entityName)
  rvar        = (1,"r")
  entvar      = (2,"ent")
  readKey     = applyF (model erdname, "read" ++ entityName ++ "Key")
                       [CVar (2,"s")]
  getEntityOp = applyF (pre ".")
                       [constF (model erdname, "runJustT"),
                        constF (model erdname, "get" ++ entityName)]
demand: Info
 argument 2
deterministic: Info
 deterministic operation
documentation: Info
 
Generates the instance declaration for a controller.
failfree: Info
 (_, _)
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {(_,{Entity}) |-> {CInstance}}
name: Info
 controllerInstDecl
precedence: Info
 no precedence defined
result-values: Info
 {CInstance}
signature: Info
 String -> Database.ERD.Entity -> AbstractCurry.Types.CInstanceDecl
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 yes
totally-defined: Info
 reducible on all ground data terms