• Stars
    star
    318
  • Rank 127,348 (Top 3 %)
  • Language
    OCaml
  • License
    Other
  • Created almost 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Malfunctional Programming

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.

More Repositories

1

jq

Command-line JSON processor
C
21,280
star
2

counterexamples

Counterexamples in Type Systems
JavaScript
281
star
3

mlsub

Prototype type inference engine
OCaml
181
star
4

crowbar

Property fuzzing for OCaml
OCaml
174
star
5

bf.sed

A brainfuck compiler, written in sed
154
star
6

ppx_stage

Staged metaprogramming in stock OCaml
OCaml
142
star
7

idris-malfunction

Experimental Malfunction backend for Idris
Haskell
82
star
8

caml-oxide

safe FFI between OCaml and Rust (experimental)
Rust
64
star
9

minhttp

A tiny and surprisingly featureful webserver
C
49
star
10

git-ls

List files, annotated by git status
Python
36
star
11

pathfinder

pythonic filesystem library
Python
35
star
12

hax

Random scripts, snippets of code, whatever.
Java
23
star
13

libfib

A library for high-performance lightweight threads
C++
19
star
14

llvm

Context switching for LLVM
C++
15
star
15

linkage

easy-to-use wrapper for OCaml's Dynlink
OCaml
15
star
16

ocaml-afl-persistent

persistent-mode afl-fuzz for ocaml
OCaml
14
star
17

Sandbox

Sandbox for running native code under Linux at full speed, without allowing it to do anything other than read/write stdio
C
12
star
18

bzseek

Random access library for bzip2 files
C
8
star
19

cshore

Call C from Python without writing bindings
C
8
star
20

moria

Embedded language for construction of DWARF
OCaml
7
star
21

with-gdb

Attaches gdb to crashed processes
C
7
star
22

nd

Netsoc LDAP directory
Python
6
star
23

wikiflow

random walks through human knowledge
5
star
24

fyp

Final year project
Haskell
5
star
25

python-monkeypatch

Bringing Ruby best practices to Python
Python
5
star
26

Altitude

Debugging above C level
C
4
star
27

clang

Clang C/C++ compiler, with patches to support context-switching
C++
4
star
28

sequent-subtyping

Coq
3
star
29

irclinks

IRC network visualisation
Python
3
star
30

seqbuf

Sequential buffer access
OCaml
3
star
31

sneeky

Steganography through bad spelling
Python
2
star
32

bandgraph

Scale-space visualisation of time-series data
Python
2
star