Skip to content

Instantly share code, notes, and snippets.

@Nymphium
Created March 6, 2025 22:20
Show Gist options
  • Save Nymphium/ff6a10272ba1bbf07d737d4fcf6b7a57 to your computer and use it in GitHub Desktop.
Save Nymphium/ff6a10272ba1bbf07d737d4fcf6b7a57 to your computer and use it in GitHub Desktop.
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