Created
March 6, 2025 22:20
-
-
Save Nymphium/ff6a10272ba1bbf07d737d4fcf6b7a57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local eff = require('eff') | |
local inst, perform, handler = eff.inst, eff.perform, eff.handler | |
local Twice = inst() | |
local Exit = inst() | |
--[[ | |
co = { | |
print(1) | |
coroutine.yield() -- *1 | |
corouitne.yield() -- *3 | |
print(2) | |
} | |
coroutine.resume(co) -- *2 | |
coroutine.resume(co) -- *4 | |
--]] | |
local h = handler { | |
[Twice] = function(k) | |
k() -- *2 | |
k() -- *4 | |
end, | |
[Exit] = function() end, | |
val = function() print("end") end | |
} | |
h(function() | |
print(1) | |
perform(Twice()) -- *1 | |
perform(Exit()) -- *3 | |
print(2) | |
end) | |
--[[ | |
expected: | |
1 | |
actual: | |
1 | |
2 | |
end | |
--]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment