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

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

types †<br />

[ makeBinding(binding_list(ffpl)) ↦→ Known(te) ],<br />

prlet),<br />

TypeName(id) →<br />

if id ∈ dom trans<br />

then<br />

/∗Formal function parameter <strong>of</strong> a type <strong>of</strong> interest.<br />

∗/<br />

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

env †<br />

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

types †<br />

makeTYPESMap(binding_list(ffpl), te),<br />

makeProductLet(<br />

te, makeBinding(binding_list(ffpl)),<br />

prlet, trans))<br />

else<br />

/∗Formal function parameter not <strong>of</strong> a type <strong>of</strong> interest.<br />

∗/<br />

(true, ffpl, env,<br />

types †<br />

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

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

end,<br />

TypeExprProduct(tep) →<br />

TRFFPProduct(<br />

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

TypeExprSet(tes) →<br />

(true, ffpl, env,<br />

types †<br />

[ makeBinding(binding_list(ffpl)) ↦→ Known(te) ],<br />

prlet),<br />

TypeExprList(tel) →<br />

(true, ffpl, env,<br />

types †<br />

[ makeBinding(binding_list(ffpl)) ↦→ Known(te) ],<br />

prlet),<br />

TypeExprMap(tem) →<br />

(true, ffpl, env,<br />

types †<br />

[ makeBinding(binding_list(ffpl)) ↦→ Known(te) ],<br />

prlet),<br />

/∗Higher order functions.∗/<br />

FunctionTypeExpr(tef, fa, rd) →<br />

190

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

Saved successfully!

Ooh no, something went wrong!