Skip to content

Use TAdd in the instance head instead of a TSub context in TupleSize#932

Merged
quark17 merged 1 commit intoB-Lang-org:mainfrom
krame505:tuple-size-tadd
Apr 26, 2026
Merged

Use TAdd in the instance head instead of a TSub context in TupleSize#932
quark17 merged 1 commit intoB-Lang-org:mainfrom
krame505:tuple-size-tadd

Conversation

@krame505
Copy link
Copy Markdown
Collaborator

This reverts commit 9d77afc.

This was a change I apparently made in #729, for reasons that I don't recall. However it turns out to cause a performance regression in our code base on a module with a huge number of input ports of complex types.

@quark17 quark17 merged commit 11afeec into B-Lang-org:main Apr 26, 2026
79 checks passed
@quark17
Copy link
Copy Markdown
Collaborator

quark17 commented Apr 26, 2026

Yeah, I avoid TSub because the undefined cases make it not entirely compatible with TAdd. Though, in this case, is it the use of a type function in the head that improves the performance? That is, would this equally perform poorly?:

instance (TupleSize' b n, Add n 1 m) => TupleSize' (a, b) m where {}

@krame505
Copy link
Copy Markdown
Collaborator Author

I didn't try that variant, but I suspect that the difference is TAdd resolves during matching without creating an additional context to solve.

@quark17
Copy link
Copy Markdown
Collaborator

quark17 commented Apr 27, 2026

But then, why doesn't TSub also resolve without needing an additional context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants