9.10 Functors

The module Functor contains procedures operating on functors.


{Functor.is +X ?B}

tests whether X is a functor.


{Functor.new <import spec> <export spec> +P ?Functor}

returns a new functor with imports as described by the <import spec>, exports as described by the <export spec>, and body as performed by P.

The <import spec> is a record mapping the name of each imported module to a record giving information about it:

<import spec> ::= 
    'import'(<module name><import info> ...
         <module name><import info>)

<module name> ::= <atom>

The optional 'from' field gives the value of this import's at clause, if given:

<import info> ::= info(type: <type> ['from'<atom>])

The type field is the expected type of the module. This can be any of the atoms returned by Value.type, plus some more implementation-specific ones, or a record with label record:

<type> ::= 
    int | atom | ...     % see above
 | record(<feature><type> ... <feature><type>)
 | nil     % no information known

The <export spec> is a record mapping each feature of the module resulting from applications of this functor to the type of the corresponding value:

<export spec> ::= 'export'(<feature><type> ... <feature><type>)

The body is a binary procedure {P <import> <export>} where:

<import> ::= 'IMPORT'(<module name><value> ... <module name><value>)

<export> ::= <value>

Denys Duchier, Leif Kornstaedt and Christian Schulte
Version 1.4.0 (20080702)