Skip to content
Discussion options

You must be logged in to vote

What I'd love is a story for this:

# [ ] (ideally) should all be H[int], since bool + bool is int
reveal_type(H(True) + H(False))  # properly typed as H[int]
reveal_type(H(True) @ 2)  # improperly flagged, but I would have at least expected H[bool]?
reveal_type(2 @ H(True))  # improperly flagged, but I would have at least expected H[bool]?

I'm guessing that this is rejected because bool + bool -> int, and CanAddSame requires some T of the form T + T -> T. So what you could do is use CanAddSame[int, int], so that this restriction is relaxed to T + T | int -> T | int, which I think should accept bool.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@posita
Comment options

@jorenham
Comment options

Answer selected by posita
@posita
Comment options

@jorenham
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants