package malfunction

  1. Overview
  2. Docs
Compiler back-end for functional languages, based on OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

malfunction-0.4.1.tbz
sha256=0d5f104c73dda414faa987ecb9daf03101e3c962919746634ad972cb2f891dd5
sha512=d1109cf4ebe671d1b8ad1210816d6e83d4bde0a14157ffb689fc129b74f2c8f4add34babad96408161c27b2fdf0dfb497cc0a9a2f16f690e7ae90fd101a71860

Description

Malfunction is a high-performance, low-level untyped program representation, designed as a target for compilers of functional programming languages.

Published: 28 Sep 2022

README

README.md

Malfunction is a high-performance, low-level untyped program representation, designed as a target for compilers of functional programming languages.

Malfunction is a revolting hack, exposing bits of the OCaml compiler's guts that were never meant to see the light of day.

"Hello, World" looks like this:

(module
  (_ (apply (global $Stdlib $print_string) "Hello, world!\n"))
  (export))

Malfunction requires OCaml (at least version 4.04.0, and you may see better performance with flambda enabled), which you should install using OPAM. Then, install malfunction using:

opam pin add malfunction git://github.com/stedolan/malfunction.git

You can then compile and run the above example with:

malfunction compile docs/helloworld.mlf -o hello
./hello

The syntax is based on s-expressions, and is designed to be easy to correctly generate, rather than to be particularly beautiful. For instance, there are no reserved words: all user-defined identifiers must be prefixed with $.

Files are compiled as OCaml modules, and may import values from OCaml (e.g. Stdlib.print_string in the example above) and export values to OCaml (using the export form). Modules written in malfunction may be combined with an mli file written in OCaml.

Malfunction makes no effort to check types. Typical programs do go wrong. Compilers targeting Malfunction need to convince themselves that their output won't go wrong, but don't need to explain their reasoning.

For more, read the spec, or the abstract submitted to the ML Workshop, or some examples

There's also an experimental backend for the dependently typed language Idris.

Dependencies (5)

  1. zarith
  2. cppo build & >= "1.1.0"
  3. dune >= "1.2"
  4. ocamlfind
  5. ocaml >= "4.04" & < "5.0.0"

Dev Dependencies (2)

  1. craml with-test
  2. omd with-test & < "2.0.0~"

Used by

None

Conflicts

None