Skip to content

Commit 9c3fc4c

Browse files
authored
Add a nested handler test (#273)
1 parent c6b81a3 commit 9c3fc4c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/ok/ok0139_nestedHandlers.fram

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
let printStrLn = extern dbl_printStrLn : String ->[IO] Unit
2+
let addInt = extern dbl_addInt : Int -> Int -> Int
3+
method toString = (extern dbl_intToString : Int -> String)
4+
5+
data Reader E X = {
6+
ask : Unit ->[E] X
7+
}
8+
9+
let hReader init =
10+
handler Reader
11+
{ ask = effect () / r => r init
12+
}
13+
end
14+
15+
let (res : Int) =
16+
handle r1 with hReader 1 in
17+
handle r2 with hReader 5 in
18+
addInt (r1.ask ()) (r2.ask ())
19+
20+
let _ = printStrLn res.toString
21+
# @stdout:6
22+

0 commit comments

Comments
 (0)