CurryInfo: spicey-4.2.0 / Spicey.ViewGeneration.entity2Tuple

definition:
entity2Tuple :: ViewGenerator
entity2Tuple erdname (Entity entityName attrlist) relationships allEntities =
  let
    manyToManyEntities = manyToMany allEntities (Entity entityName attrlist)
    manyToOneEntities  = manyToOne (Entity entityName attrlist) relationships
  in
    stCmtFunc
    ("Transformation from entity type "++entityName++" to a tuple\n"++
     "which can be used in WUI specifications.")
    (viewModuleName entityName, (lowerFirst entityName)++"2Tuple") 2 Public
    (
      foldr (CFuncType)
      (entityInterface (filter notKey attrlist)
                       manyToOneEntities manyToManyEntities)
      (
        (map ctvar manyToOneEntities) ++
        
        [(if null manyToManyEntities
            then baseType (model erdname, entityName)
            else tupleType
                  ([ctvar entityName] ++
                   map (\ (name,_) -> listType (ctvar name))
                       manyToManyEntities)
        )]
      )
    )
    [simpleRule
      ( 
        (map (\ (name, varId) -> CPVar(varId,(lowerFirst name)))
             (zip manyToOneEntities [1..])) ++
        [
         tuplePattern
          (
            CPVar (1, lowerFirst entityName) :
            (map (\ ((ename,erel), varId) ->
                     CPVar (varId, lowerFirst $ erel ++ ename ++ "s"))
                 (zip manyToManyEntities [1..]))
          )
        ]
      )
      (tupleExpr
            (map (\ (Attribute a _ _ _) ->
                     applyF (model erdname, lowerFirst entityName ++ a)
                            [cvar (lowerFirst entityName)])
                  (filter notKey attrlist) ++
             map (\e -> cvar (lowerFirst e)) manyToOneEntities ++
             map (\ (ename,erel) -> cvar (lowerFirst $ erel ++ ename ++ "s"))
                 manyToManyEntities)
        )]
demand:
argument 2
deterministic:
deterministic operation
failfree:
<FAILING>
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{(_,{Entity},_,_) |-> _}
name:
entity2Tuple
precedence:
no precedence defined
result-values:
_
signature:
String -> Database.ERD.Entity -> [Database.ERD.Relationship]
-> [Database.ERD.Entity] -> AbstractCurry.Types.CFuncDecl
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term