Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS types † [ makeBinding(binding_list(ffpl)) ↦→ Known(te) ], prlet), TypeName(id) → if id ∈ dom trans then /∗Formal function parameter of a type of interest. ∗/ (true, mk_FormalFunctionParameter(〈〉), env † [ id ↦→ makeBinding(binding_list(ffpl)) ], types † makeTYPESMap(binding_list(ffpl), te), makeProductLet( te, makeBinding(binding_list(ffpl)), prlet, trans)) else /∗Formal function parameter not of a type of interest. ∗/ (true, ffpl, env, types † [ makeBinding(binding_list(ffpl)) ↦→ Known(te) ], prlet) end, TypeExprProduct(tep) → TRFFPProduct( ffpl, tep, trans, env, types, prlet), TypeExprSet(tes) → (true, ffpl, env, types † [ makeBinding(binding_list(ffpl)) ↦→ Known(te) ], prlet), TypeExprList(tel) → (true, ffpl, env, types † [ makeBinding(binding_list(ffpl)) ↦→ Known(te) ], prlet), TypeExprMap(tem) → (true, ffpl, env, types † [ makeBinding(binding_list(ffpl)) ↦→ Known(te) ], prlet), /∗Higher order functions.∗/ FunctionTypeExpr(tef, fa, rd) → 190

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER TRFormalFuncParam( ffpl, tef, trans, env, types † [ makeBinding(binding_list(ffpl)) ↦→ Known(te) ], prlet), BracketedTypeExpr(bte) → TRFormalFuncParam( ffpl, bte, trans, env, types, prlet) end end, /∗Transforms a formal function parameter list. ∗/ /∗ Arguments: ======= ffpl: the formal function parameter list tel: the corresponding type expression list prlet: let expression used to access types of interests that are abbreviation types Result: ======= FormalFunctionParameter_list: the imperative version of the formal function parameter list LetDef_list: the resulting let expression ∗/ TRFFPProduct : FormalFunctionParameter × TypeExpr ∗ × TRANS × ENV × TYPES × LetDef ∗ → Bool × FormalFunctionParameter × ENV × TYPES × LetDef ∗ TRFFPProduct(ffpl, tel, trans, env, types, prlet) ≡ if binding_list(ffpl) = 〈〉 then if tel = 〈〉 then (false, mk_FormalFunctionParameter(〈〉), env, types, prlet) else (true, mk_FormalFunctionParameter(〈〉), env, types, prlet) end else case hd binding_list(ffpl) of 191

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER<br />

TRFormalFuncParam(<br />

ffpl, tef, trans, env,<br />

types †<br />

[ makeBinding(binding_list(ffpl)) ↦→<br />

Known(te) ], prlet),<br />

BracketedTypeExpr(bte) →<br />

TRFormalFuncParam(<br />

ffpl, bte, trans, env, types, prlet)<br />

end<br />

end,<br />

/∗Transforms a formal function parameter list.<br />

∗/<br />

/∗<br />

Arguments:<br />

=======<br />

ffpl: the formal function parameter list<br />

tel: the corresponding type expression list<br />

prlet: let expression used to access types <strong>of</strong><br />

interests that are abbreviation types<br />

Result:<br />

=======<br />

FormalFunctionParameter_list: the imperative<br />

version <strong>of</strong> the formal function parameter list<br />

LetDef_list: the resulting let expression<br />

∗/<br />

TRFFPProduct :<br />

FormalFunctionParameter × TypeExpr ∗ × TRANS ×<br />

ENV × TYPES × LetDef ∗ →<br />

Bool × FormalFunctionParameter × ENV × TYPES ×<br />

LetDef ∗<br />

TRFFPProduct(ffpl, tel, trans, env, types, prlet) ≡<br />

if binding_list(ffpl) = 〈〉<br />

then<br />

if tel = 〈〉<br />

then<br />

(false, mk_FormalFunctionParameter(〈〉), env,<br />

types, prlet)<br />

else<br />

(true, mk_FormalFunctionParameter(〈〉), env,<br />

types, prlet)<br />

end<br />

else<br />

case hd binding_list(ffpl) <strong>of</strong><br />

191

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!