-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdyn.kk
35 lines (28 loc) · 844 Bytes
/
dyn.kk
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
effect env
val mode: string
fun count(items: list<a>): int
items.length
fun really-perform(task: list<string>): <console, env> int
println(mode ++ ": " ++ task.show)
task.count
fun really-perform(task: string): <console, env> int
println(mode ++ ": " ++ task.show)
task.count
fun perform(task: list<string>): <console, env> int
really-perform(task)
fun perform(task: string): <console, env> int
really-perform(task)
// TODO Why not this?
// fun with-mode(new-mode: string, action: () -> <|e> a): <env|e> a
fun with-mode(new-mode: string, action: () -> <env|e> r): <|e> r
with val mode = new-mode
action()
fun main(): console ()
with val mode = "safe"
println(
map([
perform("something"),
with-mode("faster") { perform("reliable") },
perform(["again"]),
]) fn(it) {it.show}.join(" ")
)