26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.4. TRANSFORMING EXPLICIT FUNCTION DEFINITIONS<br />

The transformation <strong>of</strong> an explicit function definition can be done in four<br />

steps:<br />

1. <strong>Transformation</strong> <strong>of</strong> the single typing, also known as the function signature.<br />

2. <strong>Transformation</strong> <strong>of</strong> the formal function application.<br />

3. <strong>Transformation</strong> <strong>of</strong> the value expression.<br />

4. <strong>Transformation</strong> <strong>of</strong> the possible pre-condition.<br />

These steps are described below.<br />

6.4.1 Transforming Single Typings<br />

When transforming a single typing the single typing keeps its id. Only single<br />

typings in which the type expression is a function type expression are allowed.<br />

The function type expression is transformed in the following way:<br />

• The type <strong>of</strong> the arrow, either total or partial, <strong>of</strong> the type expression is<br />

preserved.<br />

• If the applicative function takes the type <strong>of</strong> interest T as argument,<br />

this is removed from the left hand side <strong>of</strong> the arrow and replaced by<br />

an access descriptor read t at the right hand side <strong>of</strong> the arrow, where<br />

t is the variable name <strong>of</strong> the type <strong>of</strong> interest.<br />

• If the applicative function returns the type <strong>of</strong> interest, this is replaced<br />

by an access descriptor write t.<br />

• Any gaps in the single typing after the above transformation are filled<br />

with Unit, that is if the whole left or right hand side <strong>of</strong> the arrow are<br />

removed.<br />

Examples <strong>of</strong> transformations <strong>of</strong> single typings are given in Table 6.1 on<br />

the following page.<br />

Furthermore, if the value expression <strong>of</strong> the function contains hidden observers<br />

or generators or implicit observers or generators, read/write access<br />

descriptors matching those <strong>of</strong> the observers/generators have to be included<br />

in the single typing. This has to be done recursively, such that if a function<br />

contains an application <strong>of</strong> a function containing observers and/or generators<br />

the appropriate read and write access descriptors matching these observers<br />

and generators have to be included in the single typing <strong>of</strong> the original function,<br />

and so on.<br />

The inclusion <strong>of</strong> both read and write access descriptors <strong>of</strong> the same<br />

variable is not necessary due to the fact that write implies read. The<br />

33

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

Saved successfully!

Ooh no, something went wrong!