4 ms·
>I'm not sure what you're trying to say here. Yes, you can implement the function, I never claimed otherwise. I'm talking about the _type system_. The type con
by corethree 3y ago
>I'm not sure what you're trying to say here. Yes, you can implement the function, I never claimed otherwise. I'm talking about the _type system_.
The type constrains the definition. Look at the definition, there is ONLY one possible definition when converting this:
Dict[str, T] -> Dict[str, Callable[[], T]]
Literally. Try to think of another way to define the lambda, you can't. The more open the type the more constrained the definition the more constrained the type the more open the definition.
> I specifically talked about arbitrary tuples. Your function only handles specific tuples.
I remarked on this in other replies. How will you define the return value of the concat and have it exactly type correct? It's not possible bro. You can't do much with tuples of arbitrary types. Not unless you have dependent types.
>The type system is a core feature of Python. Until it supports what I want, I can't really use what I want with Python.
Type checking in python is an external application. The interpreter doesn't do any type check. Type checking is achieved by running another program. All kinds of additional features and custom interpretations on types can be inserted into these type checkers.
- Timon3 3y ago> The type constrains the definition. Look at the definition, there is ONLY one possible definition when converting this: Yes, and if Python had a better type system, I could write a more concrete definition. Why don't you understand that? > I remarked on this in other replies. How will you define the return value of the concat and have it exactly type correct? It's not possible bro. You can't do much with tuples of arbitrary types. Not unless you have dependent types. Of course it's possible, the type system even supports almost everything that's necessary. You can already define what I want with a single fixed-size tuple of arbitrary size, you just can't do it with multiple ones. Why do you have this strange fixation on calling this "wrong" and "impossible"?
- corethree 3y ago>Yes, and if Python had a better type system, I could write a more concrete definition. Why don't you understand that? I understand everything. It's you who doesn't understand. What I described is for ALL type systems in general. Not python types. >Of course it's possible, the type system even supports almost everything that's necessary. You can already define what I want with a single fixed-size tuple of arbitrary size, you just can't do it with multiple ones. Why do you have this strange fixation on calling this "wrong" and "impossible"? It's not a fixation. It's because I know what I'm talking about. Look just prove it to me. Define the type signature for concat function that will concat two tuples with variadic parameters in TS. Make sure the return value has the exact required shape. Additionally don't resort to using Any. Also define the intersection function as well. Again, Don't use any. Should be trivial if what you say is true.
- Timon3 3y ago> I understand everything. It's you who doesn't understand. What I described is for ALL type systems in general. Not python types. Then why is what you're claiming to be impossible possible in Typescript? How can that be? Is the whole world wrong, aside from you? > Look just prove it to me. Define the type signature for concat function that will concat two tuples with variadic parameters in TS. You mean the one I already posted yesterday? https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UDaA7ArgWwEYQE4BooBnYXASxQHMBdAKFEigCEFksB7dgGwgEMVC6bHjq0AxuxQkovAFzIhOAsVIUarJABYATIQBEACwhcu7KAHd2uLgBM9dCVOBQs8pB258BURSI0AzXi4iCEIABlF-NBQxYDJJKH9OAB4AFV4oCAAPYAgUGyJkADoS-hAkampCVKxMnLyC4tKUcsqAPgAKOSh0wlcerABKNxKi3qhRmuooAG9aKChcCGA0XBQmot5CUaw6AF9acUlpMVYk9i6+waOpTyLTSg6xQaA https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UDaA... Or, if you prefer Python, run this: from typing import Tuple, TypeVar, TypeVarTuple, reveal_type T = TypeVar("T") Ts = TypeVarTuple("Ts") def concat(element: T, tup: Tuple[*Ts]) -> Tuple[T, *Ts]: return (element, *tup) element = "foo" tup = (True, 42) reveal_type(concat(element, tup)) You said it's impossible for the return type to be dependent on the input type. Why does Python disagree with you?
- corethree 3y agoLet me address the one in python. First off we are talking about concatenating tuples. What you're doing here is called preppending an element to a tuple. Like come on man. Have you not been reading the examples I've been posting. Your typescript example is relevant. But like I said it's an arbitrarily narrow thing. It's a special case. Typescript arbitrarily only supports only concat. Which is what I've been saying. It doesn't type level programming. >Why does Python disagree with you? There's no need to be a complete ass hole. Why does not being an ass hole disagree with you? First off your python example is completely wrong. Second off no point in saying snarky comments like that.
- Timon3 3y ago> Let me address the one in python. > First off we are talking about concatenating tuples. > What you're doing here is called preppending an element to a tuple. Like come on man. Have you not been reading the examples I've been posting. I have no idea how you still do not understand what I am talking about. My whole point is that Python doesn't support this. It has all the ingredients, it literally supports what you called impossible (having a function return a tuple type that's based on an arbitrary fixed-size input). Yes, the function doesn't support concatenating two tuples while being well-typed. That is what every single one of my messages was about. How do you read all my messages and not understand my basic argument? And, please explain in great detail: if a typing system can handle prepending/appending an element to a tuple, what is the big difference to concatenating two fixed-size tuples? Why is one obviously possible, and one isn't? What is the fundamental difference? > Your typescript example is relevant. But like I said it's an arbitrarily narrow thing. It's a special case. Typescript arbitrarily only supports only concat. Which is what I've been saying. It doesn't type level programming. First off, you're wrong, it's not an arbitrarily narrow thing - Typescript does allow much more complex operations, the type system is literally Turing-complete. But aside from that: I didn't say that it supports anything else. All I have been saying is: Typescript supports this thing, which Python does not. Why do you keep disagreeing and saying it's "wrong" and "impossible" when it does literally do what I've been telling you? > There's no need to be a complete ass hole. Why does not being an ass hole disagree with you? First off your python example is completely wrong. Second off no point in saying snarky comments like that. I have spent enough time trying to explain this to you. You're still fundamentally misunderstanding what I am talking about while acting like you know everything. You're either unable to understand it or a troll - it doesn't matter which it is.