Clean Language Report

#
Appendix D
Compiler Extensions

This appendix lists extensions and modifications to Clean that are supported by a compiler. Unfortunately they are not yet described in the previous chapters and appendices of this manual.

## D.1 Clean 3.0 Compiler Extensions

### D.1.1 New imports

Identifiers can be imported qualified by adding qualified after import in the import statement. For example:

import qualified StdList;
from StdList import qualified drop,++;

Identifiers imported in this way can be used by prefixing the identifier with the module name between single quotes and a dot. If an identifier consists of special characters (for example ++) an additional single space is required between the dot and the identifier.

For example:
f l = 'StdList'.drop 1 (l 'StdList'. ++ [2]);

Currently field names of records are not imported by an implicit qualified import, but can be imported with an explicit qualified import.

Qualified names may only be used if a qualified import is used, not if the identifier is only imported by a normal (unqualified) import. An identifier may be imported both unqualified and qualified.

Qualified imports may be used in definition modules, but qualified identifiers cannot be imported from a (definition) module.

### D.1.2 Uniqueness typing additions

Updates of unique array elements:

A unique array element of a (unique) array of unique elements can be selected and updated, if the selection (using ![ ]) and update (with the same index) occur in the same function and the array is not used in between (only the selected element is used).

For example, below a unique row is selected, updated by inc_a and finally the row of the array is updated.

inc_row :: !*{#*{#Int}} !Int -> *{#*{#Int}};
inc_row a row_i
# (row,a) = a![row_i];
row = inc_a 0 row;
= {a & [row_i]=row};
inc_a :: !Int !*{#Int} -> *{#Int};
inc_a i a
| i<size a
# (n,a) = a![i];
a & [i]=n+1;
= inc_a (i+1) a;
= a;

### D.1.3 Hierarchical modules

The module name can be used to specify the directory containing the module. In that case the module name is the list of folder names of the directory, separated by .'s, followed by a . and the file name. For example the implementation module X.Y.Z is stored in file X/Y/Z.icl (file Z.icl in subfolder Y of folder Z). The path containing the first folder (X in this case) should be a module search path for the compiler.

## D.2 Clean Development Compiler Extensions

type GenericInfo (in module StdGeneric) changed.

generic instances of generic representation types (e.g. CONS) may occur in definition modules.

builtin Maybe types added (?, ?^, ?# with constructors ?Just, ?None, ?^Just, ?^None, ?#Just, ?#None).

## D.3 Clean ITask Compiler Extensions

Function arguments may have contexts with universally quantified type variables.

Constructors may have contexts (for normal and universally quantified type variables).

dynamic types may have contexts.