-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgolden.lua
More file actions
73 lines (73 loc) · 1.96 KB
/
golden.lua
File metadata and controls
73 lines (73 loc) · 1.96 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
local function PSLUA_runtime_lazy(name)
return function(init)
return function()
local state = 0
local val = nil
if state == 2 then
return val
else
if state == 1 then
return error(name .. " was needed before it finished initializing")
else
state = 1
val = init()
state = 2
return val
end
end
end
end
end
local M = {}
M.Effect_foreign = {
pureE = function(a)
return function()
return a
end
end,
bindE = function(a)
return function(f)
return function()
return f(a())()
end
end
end
}
M.Control_Applicative_pure = function(dict) return dict.pure end
M.Effect_monadEffect = {
Applicative0 = function() return M.Effect_applicativeEffect end,
Bind1 = function() return M.Effect_bindEffect end
}
M.Effect_bindEffect = {
bind = M.Effect_foreign.bindE,
Apply0 = function() return M.Effect_Lazy_applyEffect(0) end
}
M.Effect_applicativeEffect = {
pure = M.Effect_foreign.pureE,
Apply0 = function() return M.Effect_Lazy_applyEffect(0) end
}
M.Effect_Lazy_functorEffect = PSLUA_runtime_lazy("functorEffect")(function()
return {
map = function(f)
return (M.Effect_applicativeEffect.Apply0()).apply(M.Control_Applicative_pure(M.Effect_applicativeEffect)(f))
end
}
end)
M.Effect_Lazy_applyEffect = PSLUA_runtime_lazy("applyEffect")(function()
return {
apply = (function()
return function(f)
local bind = (M.Effect_monadEffect.Bind1()).bind
return function(a)
return bind(f)(function(fPrime)
return bind(a)(function(aPrime)
return M.Control_Applicative_pure(M.Effect_monadEffect.Applicative0())(fPrime(aPrime))
end)
end)
end
end
end)(),
Functor0 = function() return M.Effect_Lazy_functorEffect(0) end
}
end)
return { main = M.Control_Applicative_pure(M.Effect_applicativeEffect)(nil) }