Skip to content

Conversation

@treeowl
Copy link

@treeowl treeowl commented Sep 9, 2019

In GHC 8.0 and later, KnownNat implies Typeable so we can implement reifyTypeable much more easily, and probably also considerably more efficiently.

@treeowl
Copy link
Author

treeowl commented Sep 9, 2019

The reason we need the Typeable a constraint is now much clearer to me: s -> a means that s must have an a in it. But that means s will only be Typeable if a is as well. That's annoying. We could offer

reifyTypeable' :: a -> (forall (s :: Nat). (Typeable s, Reifies (Stable s a) a) => Proxy s -> r) -> r

That feels a bit weird. With a bit of annoyance in the compatibility department, I'm pretty sure we could clean it up:

reifyTypeable' :: a -> (forall (k :: Type) (s :: k). (Typeable s, Reifies (Stable s a) a) => Proxy s -> r) -> r

@treeowl treeowl force-pushed the hrmp branch 3 times, most recently from 4705a92 to 468f4e9 Compare September 9, 2019 04:06
In GHC 8.0 and later, `KnownNat` implies `Typeable`. This lets us
implement `reifyTypeable` much more easily, and probably also
considerably more efficiently.
@ekmett
Copy link
Owner

ekmett commented Sep 9, 2019

This does have the downside of forcing a kind change on s in GHC 8+, so users would have to use polykinds or manually case the kind off of version numbers.

We could use a small type level shim to convert the Nat down to something of kind * and then that small wart would shave off.

@RyanGlScott
Copy link
Collaborator

Sorry for taking so long to look at this. (I think this PR predates me becoming a co-maintainer of the library.)

The new implementation of reifyTypeable looks great. I'm not quite sure what the implementation you had in mind for reifyTypeable' (alluded to in #45 (comment)) is, however. Can you post it here?

@treeowl
Copy link
Author

treeowl commented Dec 10, 2023

I'll have to page this back in....

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.

3 participants