Example Programs

To view the example programs:

  1. Start the VFPE application.
  2. Press the "load from file" pallet button (the picture of a folder).
  3. Browse to the CD "examples" folder.
  4. Select a ".sfe" (serialised functional expression) file and press the "open" button. This will pick up the selected program.
  5. Drop the program onto the placeholder at the top of the editor "Main Expression" panel.

Sorting.sfe contains functional implementations of three classic sorting algorithms. Or it would if it were present, I seem to have lost that file.

ParserCombinators.sfe contains a set of parser combinators: higher-order functions for building parsers. These functions look quite elegant, with the symmetries between, say, the sequencer and alternater combinators being clearly visible. The visual version of this program differs from the textual version: in the visual version it is clearer to omit the intermediate named expressions, which exist only to avoid very long lines of text.

Datum.sfe is a data type and parser for LISP-like expressions. The parser is constructed from the parser combinators. This program makes heavy use of partially-applied functions.

Dict.sfe is a balanced binary tree (red-black tree) implementation of a finite map type. A by-product of using tree layout of functional programs is a particular clarity in the expression of algorithms that operate of tree-structured data. An example of this is in the tree-balancing functions in the red-black tree implementation. The algorithm most clearly described with tree diagrams. The translation into procedural code usually involves complicated nested conditionals. Functional implementations that make use of pattern-matching are much clearer, and the VFPE implementation is slightly clearer again (actually looking like the original diagrams).

Here are Haskell files upon which the VFPE code is based:

ParserCombinators.hs

Datum.hs

Dict.hs

Back