Repository navigation
Compute a mapped type family's image at the use site - #61
Merged
Merged
Conversation
thomasjm
force-pushed
the
use-site-family-image
branch
from
October 13, 2026 21:01
71d6680 to
b68bad3
Compare
typeFamiliesToMapToTypeScript only handled a single-argument family with a concrete image, so
a mode-indexed family whose result is one of its own arguments was rejected outright:
type family IsHydrated (f :: Type -> Type) x y where
IsHydrated Dry x y = x
IsHydrated Wet x y = y
The use site fixes those arguments, and then the image is concrete. Substituting them before
tabulating turns such a record into one generic declaration indexed on the mode, rather than
one specialized declaration per instantiation sharing a name.
A variable that keys a mapped family is now an eligible generic variable whatever its kind,
tables are named per use site so two sites of one family don't collide, and the placeholder
each table generates is memoized per module.
Still out of reach: a family whose choice type mentions another of the record's variables, and
one whose keys aren't plain constructors (beam's Columnar).
thomasjm
force-pushed
the
use-site-family-image
branch
from
October 14, 2026 09:46
f90cc20 to
4fef560
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
typeFamiliesToMapToTypeScript only handled a single-argument family with a concrete image, so a mode-indexed family whose result is one of its own arguments was rejected outright:
type family IsHydrated (f :: Type -> Type) x y where
IsHydrated Dry x y = x
IsHydrated Wet x y = y
The use site fixes those arguments, and then the image is concrete. Substituting them before tabulating turns such a record into one generic declaration indexed on the mode, rather than one specialized declaration per instantiation sharing a name.
A variable that keys a mapped family is now an eligible generic variable whatever its kind, tables are named per use site so two sites of one family don't collide, and the placeholder each table generates is memoized per module.
Still out of reach: a family whose choice type mentions another of the record's variables, and one whose keys aren't plain constructors (beam's Columnar).