-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toPairs :: TypeRepMap f -> [(SomeTypeRep, WrapTypeable f)] #69
Comments
You can extract |
Can I? |
It might be sensible to have |
Ideally those would go in one or more separate orphans modules to avoid contagious dependencies. Pragmatically that might be more hassle than it's worth, and in any case I'm certainly +1 for centralizing them. Actually... not able to test this now, but could something like this be the basis of a more abstract mechanism?
|
The elements of typerep-map/src/Data/TypeRepMap/Internal.hs Lines 377 to 378 in 449d597
The first one is
Alternatively, using the
|
Currently we can get the first half of this via
keys
and the second viatoList
, but I see no permanent guarantee that those have the same ordering (it's implied by the internal structure, but we're explicitly not supposed to rely on that).Motivation: if your
f
includes an existential wrapper witnessing a typeclass, you can map across the elements ofTypeRepMap f
and generate a monomorphic result. Paired with the keys, this can become a regularMap
. My immediate use case is aToJSON
instance:The text was updated successfully, but these errors were encountered: