about summary refs log tree commit diff stats
path: root/types.lua
blob: dd105cf0b91addc1f53137441e5d5814ed2ae9fd (plain)
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
--- lam.types

local types = {}

types.luatype = type

function types.lamtype (x)
	if types.luatype(x) == "string" then
		return "Symbol"
	elseif types.luatype(x) == "number" then
		return "Number"
	elseif getmetatable(x) and getmetatable(x).__type then
		return getmetatable(x).__type
	elseif types.luatype(x) == "table" then
		return "List"
	else
		return types.luatype(x)
	end
end

types["number?"] = function (x) return types.lamtype(x) == "Number" end
types["symbol?"] = function (x) return types.lamtype(x) == "Symbol" end
types["list?"] = function (x) return types.lamtype(x) == "List" end
types["null?"] = function (x) return x == {} end

---
return types