Skip to content

bjornbm/adt.lua

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ADT.lua

Algebraic Data Types for Lua

local adt = require('adt')

local optional = adt.new('Some', 'None')
local Some, None = optional.Some, optional.None
--[[ or you can write:
local Some = adt.new()
local None = adt.new()
--]]

local r = Some(3)
local v = adt.match(r, {
  { Some, function(v)
    return v + 10
  end },
  { None, function()
    return 0
  end }
})

print(v) --> 13

LICENSE

MIT

About

algebraic data types for Lua

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%