8 Functors and Modular Programming

The Mozart system makes data types and and their operations available through modules. For example module Dictionary exports all the library functions for creating and operating on dictionaries. A module is simply a record, e. g.:

Some modules such as List and Dictionary are always available: they are part of the Base Environment. Others need to be explictly loaded; we have seen an example of this earlier in the course using Module.link (see Section 5.3.2).

In this chapter, we will show you how to create your own modules and what the advantages are to do so. We will introduce the notions of functors and of modular programming, and as an illustration, we will rewrite, in a modular fashion, the context-free parsers of Chapter 5.



Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)