This adds ExprTopLevel and ExprSingleton and ensures that ExprBind is now monomorphic. This corrects a previous design bug where it was not monomorphic and would thus cause spawning of many more copies than necessary. In most cases this was only harmful to memory and performance, and not behaviour, since these functions were pure, and we didn't have a test for this. This also adds a bunch more tests. Most notably, the graph shape tests generally produce smaller graphs now. Lastly, a lambda cannot have two different types when used at two different call sites. It is rare that this would be used, and when it would make sense, there are easy workarounds to accomplish equivalent goals. This was mostly authored by Sam, James helped with some cleanup and debugging. Co-authored-by: James Shubin <james@shubin.ca>
106 lines
1.7 KiB
Plaintext
106 lines
1.7 KiB
Plaintext
-- main.mcl --
|
|
# state machine that previously experienced unusable slow type unification
|
|
import "world"
|
|
|
|
$ns = "estate"
|
|
$exchanged = world.kvlookup($ns)
|
|
$state = $exchanged[$hostname] || "default"
|
|
|
|
if $state == "one" or $state == "default" {
|
|
|
|
file "/tmp/mgmt/state" {
|
|
content => "state: one\n",
|
|
}
|
|
|
|
exec "timer" {
|
|
cmd => "/usr/bin/sleep 1s",
|
|
}
|
|
kv "${ns}" {
|
|
key => $ns,
|
|
value => "two",
|
|
}
|
|
Exec["timer"] -> Kv["${ns}"]
|
|
}
|
|
if $state == "two" {
|
|
|
|
file "/tmp/mgmt/state" {
|
|
content => "state: two\n",
|
|
}
|
|
|
|
exec "timer" {
|
|
cmd => "/usr/bin/sleep 1s",
|
|
}
|
|
kv "${ns}" {
|
|
key => $ns,
|
|
value => "three",
|
|
}
|
|
Exec["timer"] -> Kv["${ns}"]
|
|
}
|
|
if $state == "three" {
|
|
|
|
file "/tmp/mgmt/state" {
|
|
content => "state: three\n",
|
|
}
|
|
|
|
exec "timer" {
|
|
cmd => "/usr/bin/sleep 1s",
|
|
}
|
|
kv "${ns}" {
|
|
key => $ns,
|
|
value => "one",
|
|
}
|
|
Exec["timer"] -> Kv["${ns}"]
|
|
}
|
|
-- OUTPUT --
|
|
Edge: FuncValue -> call # fn
|
|
Edge: FuncValue -> call # fn
|
|
Edge: FuncValue -> call # fn
|
|
Edge: FuncValue -> call # fn
|
|
Edge: FuncValue -> call # fn
|
|
Edge: FuncValue -> call # fn
|
|
Edge: FuncValue -> call # fn
|
|
Vertex: FuncValue
|
|
Vertex: FuncValue
|
|
Vertex: FuncValue
|
|
Vertex: FuncValue
|
|
Vertex: FuncValue
|
|
Vertex: FuncValue
|
|
Vertex: FuncValue
|
|
Vertex: call
|
|
Vertex: call
|
|
Vertex: call
|
|
Vertex: call
|
|
Vertex: call
|
|
Vertex: call
|
|
Vertex: call
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|
|
Vertex: const
|