Created
August 10, 2023 13:31
-
-
Save danidiaz/cc1c2d1d970e44499c4195e3d2556e39 to your computer and use it in GitHub Desktop.
This file contains 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
-- code by mniip | |
types :: [String] | |
types = $( | |
do | |
insts <- reifyInstances ''Exception [VarT (mkName "a")] | |
let | |
tyConOf (AppT ty _) = tyConOf ty | |
tyConOf (ConT con) = Just con | |
tyConOf _ = Nothing | |
tyCons <- for insts \case | |
InstanceD _ _ (AppT (ConT exc) ty) _ | |
| exc == ''Exception | |
, Just tyCon <- tyConOf ty | |
-> pure tyCon | |
Language.Haskell.TH.Syntax.lift $ show <$> filter ((Just "base" ==) . namePackage) tyCons | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment