Add collections module

This commit is contained in:
Shunsuke Shibayama 2022-12-14 17:48:06 +09:00
parent 157c0cb7a5
commit 7b16e413f7
2 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,11 @@
.abc = pyimport "abc"
.NamedTuple = 'namedtuple': ClassType
.Deque = 'deque': ClassType
.ChainMap: ClassType
.Counter: ClassType
.OrderedDict: ClassType
.Defaultdict = 'defaultDict': ClassType
.UserDict: ClassType
.UserList: ClassType
.UserString: ClassType

View file

@ -0,0 +1,13 @@
.Container = Trait { .__contains__ = (self: Self) -> Bool }
.Hashable = Trait { .__hash__ = (self: Self) -> Nat }
.Sized = Trait { .__len__ = (self: Self) -> Nat }
# TODO: varargs
.Callable = Trait { .__call__ = (self: Self) -> Obj }
# .Iterable T = Trait { .__iter__ = (self: Self) -> Iterator T }
.Iterable = Trait { .__iter__ = (self: Self) -> .Iterator }
.Collection = Subsume .Container and .Iterable
# .Iterator T = Trait { .__next__ = (self: Self) -> T }
.Iterator = Trait { .__next__ = (self: Self) -> Obj }
.Reversible = Trait { .__reversed__ = (self: Self) -> .Iterator }
.Genertor = Subsume .Iterator
.Sequence = Subsume .Collection and .Sized and .Reversible