about summary refs log tree commit diff stats
path: root/types.lua
diff options
context:
space:
mode:
Diffstat (limited to 'types.lua')
-rw-r--r--types.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/types.lua b/types.lua new file mode 100644 index 0000000..dd105cf --- /dev/null +++ b/types.lua
@@ -0,0 +1,27 @@
1--- lam.types
2
3local types = {}
4
5types.luatype = type
6
7function types.lamtype (x)
8 if types.luatype(x) == "string" then
9 return "Symbol"
10 elseif types.luatype(x) == "number" then
11 return "Number"
12 elseif getmetatable(x) and getmetatable(x).__type then
13 return getmetatable(x).__type
14 elseif types.luatype(x) == "table" then
15 return "List"
16 else
17 return types.luatype(x)
18 end
19end
20
21types["number?"] = function (x) return types.lamtype(x) == "Number" end
22types["symbol?"] = function (x) return types.lamtype(x) == "Symbol" end
23types["list?"] = function (x) return types.lamtype(x) == "List" end
24types["null?"] = function (x) return x == {} end
25
26---
27return types