You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec-draft.rst
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,7 @@ Big Q: what should be an error and what should return Never?
18
18
# *[... for t in ...] arguments
19
19
| <ident>[<variadic-type-arg(<type>)> +]
20
20
21
-
# This is syntax because taking an int literal makes it a
22
-
# special form.
23
-
| GetArg[<type>, <int-literal>]
21
+
| <string-or-int-literal> # Only accepted in arguments to new functions?
24
22
25
23
26
24
# Type conditional checks are just boolean compositions of
@@ -48,12 +46,15 @@ Big Q: what should be an error and what should return Never?
48
46
if <type-bool>
49
47
50
48
51
-
``type-for(T)`` is a parameterized grammar rule, which can take
52
-
different types. Not sure if we actually need this though---now it is
53
-
only used for Any/All.
49
+
``type-for(T)`` is a parameterized grammar rule, which can take different types. Not sure if we actually need this though---now it is only used for Any/All.
54
50
55
51
---
56
52
53
+
* ``GetArg[T, Base, Idx: Literal[str]]`` - returns the type argument number ``Idx`` to ``T`` when interpreted as ``Base``, or ``Never`` if it cannot be. (That is, if we have ``class A(B[int]): ...``, then ``GetArg[A, B, 0] == int``.)
54
+
* ``GetArgs[T, Base]`` - returns a tuple containing all of the type arguments of ``T`` when interpreted as ``Base``, or ``Never`` if it cannot be.
55
+
* ``FromUnion[T]`` - returns a tuple containing all of the union elements, or a 1-ary tuple containing T if it is not a union.
56
+
57
+
57
58
# TODO: NewProtocol needs a way of doing bases also...
58
59
# TODO: New TypedDict setup
59
60
@@ -77,10 +78,6 @@ only used for Any/All.
77
78
78
79
# TODO: how to deal with special forms like Callable and tuple[T, ...]
79
80
80
-
* ``GetArgs[T]`` - returns a tuple containing all of the type arguments
81
-
* ``FromUnion[T]`` - returns a tuple containing all of the union
82
-
elements, or a 1-ary tuple containing T if it is not a union.
83
-
84
81
# TODO: How to do IsUnion? Might need a ``Length`` for tuples?
0 commit comments