-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support ghc 9.6 #31
Support ghc 9.6 #31
Conversation
@@ -54,7 +54,7 @@ pattern Some x = This x | |||
#endif | |||
|
|||
-- Do not export this type family, it must remain empty. It's used as a way to trick GHC into not unifying certain type variables. | |||
type family Skolem :: k -> k | |||
data family Skolem :: k -> k |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent a couple hours adding traces and very confused on why a gazillion instances were being returned until I remembered about obsidiansystems/dependent-sum-template#7
Shouldn't the chunk of code that's equal between the two libs be re-used instead?
aeson-gadt-th/src/Data/Aeson/GADT/TH.hs
Lines 57 to 82 in 71a315a
type family Skolem :: k -> k | |
skolemize :: Set Name -> Type -> Type | |
skolemize rigids t = case t of | |
ForallT bndrs cxt t' -> ForallT bndrs cxt (skolemize (Set.difference rigids (Set.fromList (map tvName bndrs))) t') | |
AppT t1 t2 -> AppT (skolemize rigids t1) (skolemize rigids t2) | |
SigT t1 k -> SigT (skolemize rigids t1) k | |
VarT v -> if Set.member v rigids | |
then AppT (ConT ''Skolem) (VarT v) | |
else t | |
InfixT t1 n t2 -> InfixT (skolemize rigids t1) n (skolemize rigids t2) | |
UInfixT t1 n t2 -> UInfixT (skolemize rigids t1) n (skolemize rigids t2) | |
ParensT t1 -> ParensT (skolemize rigids t1) | |
_ -> t | |
reifyInstancesWithRigids :: Set Name -> Name -> [Type] -> Q [InstanceDec] | |
reifyInstancesWithRigids rigids cls tys = reifyInstances cls (map (skolemize rigids) tys) | |
-- | Determine the type variables which occur freely in a type. | |
freeTypeVariables :: Type -> Set Name | |
freeTypeVariables t = case t of | |
ForallT bndrs _ t' -> Set.difference (freeTypeVariables t') (Set.fromList (map tvName bndrs)) | |
AppT t1 t2 -> Set.union (freeTypeVariables t1) (freeTypeVariables t2) | |
SigT t1 _ -> freeTypeVariables t1 | |
VarT n -> Set.singleton n | |
_ -> Set.empty |
On top of #30