-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.html
62 lines (54 loc) · 1.58 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MLsub type inference</title>
<script type="text/javascript" src="mlsub.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>MLsub type inference</h1>
<p>This is a demo of the prototype MLsub type inference engine,
which does Hindley-Milner style type inference with
subtyping. Edit the code on the left, and its type will be printed
on the right.</p>
<p>The syntax is a fragment of OCaml, with functions, let, lists, and records.</p>
<div id="content">
<div id="left">
<textarea id="input">
let id = fun x -> x
let rec map = fun f -> fun l ->
match l with
[] -> []
| x :: xs -> f x :: map f xs
let twice = fun f -> fun x -> f (f x)
let object1 = { x = 42; y = id }
let object2 = { x = 17; y = false }
let pick_an_object = fun b ->
if b then object1 else object2
let list_of_objects =
[object1; object2]
let x_fields = map (fun o -> o.x) list_of_objects
let rec recursive_monster = fun x ->
{ thing = x;
self = recursive_monster x }
</textarea>
</div>
<div id="right">
<div id="output"></div>
</div>
</div>
<p>
The MLsub typechecker is written in OCaml, and the code is
available
on <a href="https://github.com/stedolan/mlsub">github</a>.
</p>
<p>
The demo above is the was compiled to javascript from the MLsub
source
using <a href="http://ocsigen.org/js_of_ocaml/">js_of_ocaml</a>,
and the colors on this page
are from <a href="http://ethanschoonover.com/solarized">Solarized</a>.
</p>
</body>
</html>