%TEX 
\subsection{DefVal.}
%
%TEX
Write out VAtom.
%
defval(>node,>VType*typfun cs*v atom):
    where (>v atom ,VAtom*_>), ->,
    where (>node,df*org*a*rest>),
    get atom result type (>typfun cs, fun args>,result type>),
    where (>LIST*fun args, fun arg list>),
    repair (>node,>DefAtom,>org*a*fun arg list*result type);
defval(>node,>VType*t):
    where (>node,df*origen*a>),
    where (>a,name ce*rest>),
    repair(>a,>name ce,>t).

get atom result type (>TypFun*arg*rest, arg*arg list>, result>): ->,
    get atom result type (>rest, arg list> ,result>);
get atom result type (>r, empty>,r>):.


%TEX
\subsection{DefTyp.}
%

def typ (>node,>org,>n,>TypAtom*_): ->,
    repair (>node,>DefBasetype, >org*n); 
def typ (>node,>org,>n,>t):
     trans typ (>t,>t).


%TEX
\subsection{Type structures.}

Expand type power.
%
type power (>node, >type, >ParInt* I NUM * power):->,
    expand typpow (>type,>power,field list>),
    repair (>node,>TypProd,>LIST*fieldlist);
type power (>node, >type,>args):
    repair (>node,>TypErr,>STRING*"*** Failed to expand power type ").
    

expand typpow(>type,>"0",empty>):->;
expand typpow(>type,>p,type*r fld>):
    dc (>p+" 1 -ps.\n",pp>),
    expand typpow (>type ,>pp,rfld>).

%TEX
\subsection{Transform types Typxxx}
%

trans typ(> node, > TypAtom * atomnm): ->,
        repair (>node, >TypBase,> atomnm);
trans typ(> node, > TypFun * funpar* funres): ->,
	trans typ (> funpar, >funpar),
	trans typ (> funres, >funres);
trans typ(> node, > TypIn * ityp): ->,
	trans typ (> ityp, >ityp);
trans typ(> node, > TypOut * otyp): ->,
	trans typ (> otyp, >otyp);
trans typ(> node, > TypUni * uityp* uotyp): ->,
	trans typ (> uityp, >uityp),
	trans typ (> uotyp, >uotyp);
trans typ(> node, > TypNon * nontyp): ->,
	trans typ (> nontyp, >nontyp);
trans typ (>constant ,> TypInt): ->,
        assign (> TypInt, >PTInt, o>);
trans typ (> node,> TypFlo): ->,
        assign (> TypFlo, >PTFlo, o>);
trans typ (> node,> TypString): ->,
        assign (> TypString, >PTStr, o>);
trans typ (> node,> TypBool): ->,
        assign (> TypBool, >PTBool, o>);
trans typ (> constant,> TypAppset): ->;
trans typ(> node, > TypPwr * pwrtyp* pwrval): ->,
	trans typ (> pwrtyp, >pwrtyp),
	trans val (> pwrval, >pwrval,>empty),
        type power (>node,>pwrtyp,>pwrval); 
trans typ(> node, > TypProd * ptypes): ->,
	trans typ list (> ptypes, >ptypes);
trans typ(> node, > TypStar * startyp): ->,
	trans typ (> startyp, >startyp);
trans typ(> node, > TypLocal * locsyms* loctyp): ->,
	trans typ (> loctyp, >loctyp);
trans typ(> node, > TypSym * sym): ->;
trans typ(> node, > TypBind * boundname): ->;
trans typ (> x,> x):. 


%TEX
\subsection{Transform formal connections FCxxx}
%
trans formcon(> node, > FCList * fclist): ->,
	trans formcon list (> fclist, >fclist);
trans formcon(> node, > FCSym * fcsym): ->;
trans formcon(> node, > FCComp * fcfirct* fcrest): ->,
	trans formcon (> fcfirct, >fcfirct),
	trans formcon (> fcrest, >fcrest);
trans formcon (> constant,> FpEmpty):->; 
trans formcon (> constant,> FCErr): .
