diff --git a/toy-impl/primitives.py b/toy-impl/primitives.py index 635c5de..5b3edd6 100644 --- a/toy-impl/primitives.py +++ b/toy-impl/primitives.py @@ -12,6 +12,7 @@ i64 = types['int64'] f32 = types['float'] b = types['bool'] I = TypeVariable('I', [i32, i64, f32]) +A = TypeVariable('A', []) def impl_math(ty): ty.methods['__add__'] = ([SelfType(), ty], ty, set()) @@ -66,4 +67,6 @@ i64.methods['__init__'] = ([SelfType(), I], None, {'I'}) f32.methods['__init__'] = ([SelfType(), I], None, {'I'}) simplest_ctx = Context({}, types) +simplest_ctx.functions['len'] = ([ListType(A)], i32, {'A'}) +simplest_ctx.functions['range'] = ([i32], ListType(i32), set())