Commit 9e46d88a authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

Typeable: Generalize kind of represented type

This allows withTypeable to be used with things that are of kind other
than Type.

Test Plan: Validate

Reviewers: austin, hvr, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, thomie, dfeuer

Differential Revision: https://phabricator.haskell.org/D3996
parent cc6be3a2
......@@ -323,13 +323,14 @@ splitApp rep@(TrFun _ a b) = Just (IsApp (mkTrApp arr a) b)
splitApp (TrTyCon{}) = Nothing
-- | Use a 'TypeRep' as 'Typeable' evidence.
withTypeable :: forall a r. TypeRep a -> (Typeable a => r) -> r
withTypeable :: forall (a :: k) (r :: TYPE rep). ()
=> TypeRep a -> (Typeable a => r) -> r
withTypeable rep k = unsafeCoerce k' rep
where k' :: Gift a r
k' = Gift k
-- | A helper to satisfy the type checker in 'withTypeable'.
newtype Gift a r = Gift (Typeable a => r)
newtype Gift a (r :: TYPE rep) = Gift (Typeable a => r)
-- | Pattern match on a type constructor
pattern Con :: forall k (a :: k). TyCon -> TypeRep a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment