some manage frame progress

This commit is contained in:
Simon Hirsig
2015-10-27 13:23:35 +01:00
parent 661f7ba5dd
commit 2cd1f43bc8
2 changed files with 78 additions and 15 deletions
+42
View File
@@ -356,3 +356,45 @@ function Aux.util.set()
return self
end
function Aux.util.maybe(value)
local self = {}
function self.join()
if value == nil then
return Aux.util.maybe()
else
return value
end
end
function self.map(f)
if value == nil then
return Aux.util.maybe()
else
return maybe(f(value))
end
end
function self.bind(f)
return self.map(f).join()
end
function self.get()
return value
end
function self.or_else(default_value)
if value == nil then
return default_value
else
return value
end
end
function self.present()
return value ~= nil
end
return self
end