CurryInfo: spicey-4.2.0 / Spicey.ViewGeneration.tuple2Entity

definition:
tuple2Entity :: ViewGenerator
tuple2Entity erdname (Entity entityName attrlist) relationships allEntities =
  let
    manyToManyEntities = manyToMany allEntities (Entity entityName attrlist)
    manyToOneEntities = manyToOne (Entity entityName attrlist) relationships
  in
    stCmtFunc 
    ("Transformation from data of a WUI form to entity type "++entityName++".")
    (viewModuleName entityName, "tuple2"++entityName) 2 Public
    (
     foldr CFuncType
      (if null manyToManyEntities
       then baseType (model erdname, entityName)
       else tupleType ([ctvar entityName] ++
                       map (\ (ename,_) -> listType (ctvar ename))
                           manyToManyEntities)
      )
      ([ctvar entityName] ++
       [entityInterface (filter notKey attrlist)
                        manyToOneEntities manyToManyEntities])
    )
    [simpleRule
      ( 
        [ CPVar (1, lowerFirst entityName ++ "ToUpdate"),
          tuplePattern
           (
            (map (\ ((Attribute name _ _ _), varId) ->
                       CPVar (varId,lowerFirst name)))
                 (zip (filter notKey attrlist) [1..]) ++
            (map (\ (name, varId) -> CPVar(varId,lowerFirst name))
                 (zip manyToOneEntities [1..])) ++
            (map (\ ((ename,erel), varId) ->
                         CPVar (varId, lowerFirst $ erel ++ ename ++ "s"))
                 (zip manyToManyEntities [1..]))
           )
        ]
      )
      (tupleExpr $
         (foldr (\ (Attribute aname domain _ _) expr ->
                   case domain of
                     KeyDom rel ->
                       applyF (model erdname, "set" ++ entityName ++ aname)
                              [expr,
                               applyF (model erdname, lowerFirst rel ++ "Key")
                                      [CVar (1, lowerFirst rel)]]
                     _ -> applyF (model erdname, "set" ++ entityName ++ aname)
                                 [expr,  CVar (1, lowerFirst aname)]  )
                
                 (CVar (0, lowerFirst $ entityName++"ToUpdate"))
                 attrlist )
            : (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:
tuple2Entity
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