Fun in OCaml (Programming Languages)
From Spivey's Corner
Our interpreters for non-pure Fun that are written in (pure) Haskell can't really be regarded as practical, because memory states are represented as mappings in an applicative way, and this can't hope to compete with the destructively updated memory cells that real computers provide.
As a demonstration that reasonably practical interpreters are not far away from the pure interpreters we study in the course, here is an interpreter for Fun with memory that's written in the almost-functional language Objective Caml, using mutable reference cells to implement the memory cells in Fun. The source code is packaged with a Makefile and is identical for Linux and Windows.
Haskell aficionados would of course point out that it's possible to write non-pure programs in Haskell too, and that the interface for doing so is in fact a monad – the IO monad that's also used to allow Haskell programs to do input and output.
- Source for the interpreter: Gzipped tar format, Windows ZIP format.
| Programming Languages |
| Syllabus |
| Outline |
| Problems |
| Labs |
| Software |
| FAQ |