forked from hkust-taco/mlstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal_testing.html
More file actions
75 lines (65 loc) · 1.5 KB
/
Copy pathlocal_testing.html
File metadata and controls
75 lines (65 loc) · 1.5 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="index.css">
<title>MLstruct demonstration</title>
</head>
<body>
<h1>MLstruct demonstration</h1>
<div id="content">
<textarea id="mlscript-input" class="panel" spellcheck="false">
class Left[A]: { value: A }
def Left value = Left{ value }
class Right[A]: { value: A }
def Right value = Right{ value }
def testVal = if true then Left 1 else Right 2
def res = case testVal of
{ Left -> testVal.value
| Right -> 1
}
def zero = 0
def bruh = "Bruh"
def two = add 1 zero
def lambda = fun x -> x
def simpleLet = let i = 0 in add i 1
def f: (int & 'a) -> (int & 'a) -> 'a
def f a b = if gt a b then a else b
f 1 2
def test x = case x of
{ Left -> x.value
| Right -> "nope"
}
def tmp = test (if true then Left 1 else Right 2)
case tmp of { int -> tmp | string -> 0 }
def test2 x = case x of
{ int -> x
| bool -> x
| string -> x
}
test2 1
test2 true
test2 "a"
def test3 x = case x of
{ 1 -> true
| true -> true
| "a" -> true
| _ -> false
}
test3 1
test3 true
test3 "a"
test3 2
test3 false
test3 "oops"
test3 {}
</textarea>
<!-- let rec recursive_monster = fun x ->
{ thing = x;
self = recursive_monster x } -->
<div id="mlscript-output" class="panel"></div>
</div>
<script type="text/javascript" src="js/target/scala-2.13/mlscript-fastopt/main.js"></script>
<br/>
<p>The code is available <a href="https://github.com/hkust-taco/mlstruct">on github</a>.</p>
</html>