Last modified: Thu Oct 19, 2001

Data Field Haskell Extensions

Data Field Haskell extends Haskell with the following classes, data types, functions, and constructs. They are provided by the Datafield and Pord modules, additions to the Show and Eval classes, and some constructs which are added directly to the language. The descriptions here are informal and the list is not complete. A full account is given in Jonas Holmerin's masters thesis. There is also detailed online documentation of the extensions: the Datafield and Pord modules, and the other extensions.

Warning: this text was originally written for the Haskell 1.3 version of the language and has not been scanned for updates to the Haskell 98 version. Minor details may thus be obsolete.

Classes and Data Types

Basic Operations on Data Fields

Construction of Bounds

Here are some illustrations of bounds: dense and sparse one-dimensional bounds,

and two-dimensional bounds: some product bounds, and a sparse bound.

Operations on Bounds

The tables below give the result "type" of join and meet as a function of the argument "types". E = empty, U = universe, S = sparse, D = dense, P = predicate, x = product bound. "S/P" in the table for join means that the result is sparse if the product bound is finite, and a predicate otherwise.

meetEUSDPx
E EEEEEE
U USDPx
S SSSS
D DSx
P PP
x x

joinEUSDPx
E EUSDPx
U UUUUU
S SSPS/P
D DPx
P PP
x x

Here are some illustrations of meet: between dense and sparse one-dimensional bounds,

and two-dimensional bounds: between product bounds, and between a product and a sparse bound.

Note how meet on product bounds is applied elementwise. join works in the following way: for one-dimensional bounds,

and some two-dimensional bounds.

Again, note how also join on product bounds is applied elementwise. Furthermore note that join on dense bounds may yield an overapproximation of the union on the corresponding sets.

Operations on Finite Data Fields

Miscellaneous

Forall-abstraction

The syntax of forall-abstraction is precisely analogous to the syntax of lambda-abstraction. Its most general form involves pattern-matching on its arguments:

forall apat1 ... apatn -> exp

which can be resolved into a simpler, equivalent form, just as for lambda-abstraction. See here for details. Of particular importance is pattern-matching over simple tuples:

forall ( x1, ...,xn ) -> exp

which can be used to define multidimensional data fields. As for lambda-abstraction, this is distinct from

forall x1 ... xn -> exp

which defines a nested data field. All forall-expressions can be translated into a forall-expression with the outermost abstraction being over a single variable. The semantics for such an expression forall x -> e is

datafield (\x -> e) B(e,{x},Ø)

where B(e,{x},Ø) is a bound which is derived from the body e of the forall-expression. B(e,{x},Ø) is defined in such a way that the set it defines contains the domain of \x -> e. For a precise definition of the semantics of forall-abstraction, see here. For a more informal description of the semantics, which gives some more intuition, see here.

For-abstraction

For-abstraction provides a syntax to define a data field by cases over different parts of its domain. It is thus more explicit than forall-abstraction. The syntax is

for pat in { e1 -> e1' ; ... ; en -> en' }

Here, the expressions ei are bounds and each ei' defines the value of the data field within the set defined by ei. The bound of the data field is enclosed in the union (join) of the different ei (it can possibly be further restricted by the different ei'). If bounds overlap, then the leftmost ei' has precedence within the area of overlap. For a precise definition of the semantics of for-abstraction, see here.

Björn Lisper,
bjorn.lisper@mdh.se