Specification of the type t list |
This type gives each list of elements of A a representation (or a unique representation if and only if t gives each element of A a unique representation).
It is equipped with these five functions:
- These constructors:
- The basic constructor
empty_list constructs the representation of the empty list.
- The inductive constructor
cons_list constructs a (or the) representation of the list whose first element is x and whose rest is lx given a pair (x,lx) where x is an element of A and lx is a list of elements of A.
- The predicate function
is_empty_list checks whether a list of elements of A is empty.
- The accessors
head and tail access the first element and the rest of a non-empty list of elements of A.
The interface definition of the module (i.e. the content of the List_1.mli file) shows the types of these five functions:
val empty_list : unit -> 'a list
val cons_list : 'a * 'a list -> 'a list
val is_empty_list : 'a list -> bool
val head : 'a list -> 'a
val tail : 'a list -> 'a list
|
It also indicates that these functions are polymorphic: t can be any type, which is expressed by the type variable 'a .
|