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.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/types.lua b/types.lua new file mode 100644 index 0000000..042edce --- /dev/null +++ b/types.lua
@@ -0,0 +1,37 @@
1--- lam.types
2
3local types = {}
4
5function types.Type(x)
6 if type(x) == "string" then
7 -- Symbols are Lua strings
8 return "Symbol"
9 elseif type(x) == "number" then
10 -- Numbers are Lua numbers
11 return "Number"
12 elseif x.__type then
13 return x.__type
14 elseif type(x) == "table" then
15 -- Lists are Lua tables (non-adorned)
16 return "List"
17 else
18 return type(x)
19 end
20end
21
22types.Object = { __type = "Object" }
23function types.Object:new(o)
24 o = o or {}
25 setmetatable(o, self)
26 self.__index = self
27 return o
28end
29
30--- Boxed types
31
32-- Strings
33
34-- Lists
35
36---
37return types