diff options
Diffstat (limited to 'alv')
| -rw-r--r-- | alv/type.moon | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/alv/type.moon b/alv/type.moon index 5c76b86..4367bd2 100644 --- a/alv/type.moon +++ b/alv/type.moon @@ -52,7 +52,12 @@ class Type -- -- @type Primitive class Primitive extends Type - pp: (value) => tostring value + pp: (value) => + switch @name + when 'str' + string.format '%q', value + else + tostring value __eq: (other) => @name == other.name __tostring: => @name @@ -70,12 +75,12 @@ class Primitive extends Type -- @type Struct class Struct extends Type pp: (value) => - inner = table.concat ["#{k}: #{@types[k]\pp v}" for k, v in opairs value], ', ' + inner = table.concat ["#{k}: #{@types[k]\pp v}" for k, v in opairs value], ' ' "{#{inner}}" __eq: (other) => same @types, other.types __tostring: => - inner = table.concat ["#{k}: #{v}" for k, v in opairs @types], ', ' + inner = table.concat ["#{k}: #{v}" for k, v in opairs @types], ' ' "{#{inner}}" --- create a new struct type with a subset of keys. |
