The List Object

The List object in the Code namespace is frequently used in clauses.

There are a few properties of the List object that are worth noting. First, the List object is a monoid with type definition:

List :: [U] → U

where "U" is a type variable.

Second, one of the primary purposes for creating the List object is to use it as a container for lists of clauses. This is particularly common in cases where a function is intended to return multiple results. It's common in these situations for some of the clauses inside of the List object to evaluate to null either because the pattern match fails or because the build expression on the right-hand side of an Assert evaluates to null. But we don't want the entire List object to evaluate to null just because one of the clauses is null. Instead, after evaluating the clauses in the list, the List object should contain only the non-null results.

One way to implement this is to identify the null object and the zero parameter List:

List[] = null

Since the List object is a monoid, we have for example:

List[a, null, b] = List[a, List[], b] = List[a, b]

which gives us the desired behavior.

Because of this identification of List[] and null, the List object is different from most other objects because it that has the property of not being null even if one of its parameters is null. The ElseList object also has this same property.