This package contains a simple interpreter of Caml with various algorithms such as static binding and static typing.
Note
Check DeepAI. The image was generated using Generative AI with the following prompt.
Camel with a tshirt containing a haskell logo, sitting in front of the computers.
Firstly, build the docker image:
make build_docker
If you want to start the container and you have not already created it use:
make run_docker
Otherwise attach to the container:
make start_docker
If you want to delete the container run:
docker container rm ocamlhi
make build
Index | Features |
---|---|
01 | Simple types: char, double, int, string |
02 | Arithmetic, Comparisons |
03 | Conditional expressions (if then else) |
04 | Functions with multiple parameters, Recursion |
05 | Anonymous functions, Higher-order functions, Partial application |
06 | Static binding |
07 | Imperative programming (for loop, while loop) |
08 | Pattern matching |
09 | Operations on lists (head, map, tail) |
10 | Syntactic sugar for lists (x:y:tl) |
11 | Polymorphic lists: ('a -> 'a) list, 'a list list |
12 | Recursive data types ('a tree) |
13 | Static typing |
14 | Generalized algebraic data types: Either, Maybe, Pair |
15 | Records, References (assignments) |
16 | Tuples |
17 | Modules |
To run the tests, use one of the following:
make test
python3 unittests.py [--print_failed]
./ocamlhi -I tests/stdlib -I tests/good 01_Constants.ml
Tip
If the output is "Killed" you probably have exceeded timeout (timeout = 1s). You may try to run the test manually (without using Python).
You can also compare the results with the original OCaml interpreter (v.4.05.0). Unfortunately, opam cannot be used during building of the image. Thus you have to install it before testing.
make install_ocaml
make test_ocaml
You can test the style of the source code by using:
make install_haskell
make test_style
If you need to update the grammar you can:
- Modify the ocaml.fc file.
- Run
make bnfc
- Resolve changes manually.
- Be 'compatible' with Ocaml API.
- Fix static typing. (aliases)
- Add private module members.
- Add a garbage collector.
- Integer emulation... Is 'int' bignum in ocaml?
- Extend modules. Implement 'include' and 'open'.
- Implement classes (object-oriented programming).
- Implement multithreading and synchronization.
- Implement lazy variables.
- Implement catching exceptions. (raise / catch)
- Implement exhaustiveness checks for pattern matching.
- Implement recursive module signatures.
- Implement a command line interpreter (REPL).
- OCaml programming book
- OCaml language description
- OCaml BNF syntax
- Menhir Manual
- Modules in Ocaml
- Operators in Ocaml
- Grammar of operators in Ocaml
- OCamli - Ocaml interpreter in Ocaml (BSD)
- BNF converter (GPL)
- Happy - Parser generator (BSD)
- Alex - Lexical analyser generator (BSD)
- Haskell documentation - Profiling
- Stack Overflow - Why is impredicative polymorphism allowed only for functions in Haskell?
- TH - Template Haskell tutorial by Mark Karpov
- PathDB
- ruslanspivak.com - Algorithm for nesting scopes in Python
- unification-fd example
- Monadic Compilers for Programming Languages
- Polymorphism in Ocaml - Ad-hoc, parametric, inclusion/subtyping
- Dezani, Mariangiola & Giannini, Paola & Zucca, Elena. (2009). The essence of static and dynamic bindings. 99-106.
- Erkok (2002). Value Recursion in Monadic Computations
- Vytiniotis, Peyton Jones, Schrijvers, Sulzmann (2010). OutsideIn(X) Modular type inference with local assumptions
- Mark P. Jones (2000). Typing Haskell in Haskell
- Xavier Leroy (1992). Polymorphic typing of an algorithmic language
- David J. King, John Launchbury (1998). Lazy Depth-First Search and Linear Graph Algorithms in Haskell.