Permalink
Browse files

Start introspection util module.

  • Loading branch information...
1 parent de61513 commit 9fc53b0f0da437cbcd6357fc11758a6526ed0c82 @nominolo nominolo committed Oct 20, 2008
Showing with 30 additions and 0 deletions.
  1. +1 −0 scion.cabal
  2. +29 −0 src/Scion/Inspect.hs
View
@@ -22,6 +22,7 @@ library
-- extensions: Rank2Types
exposed-modules:
Scion.Types,
+ Scion.Inspect,
Scion
View
@@ -0,0 +1,29 @@
+{-# LANGUAGE PatternGuards #-}
+module Scion.Inspect where
+
+import GHC
+import GHC.SYB.Instances
+import SrcLoc
+
+typeDecls :: TypecheckedMod m => m -> [LTyClDecl Name]
+typeDecls m | Just (grp, _, _, _, _) <- renamedSource m =
+ [ t | t <- hs_tyclds grp
+ , isDataDecl (unLoc t)
+ || isTypeDecl (unLoc t)
+ || isSynDecl (unLoc t) ]
+ -- XXX: include families?
+typeDecls _ = error "No renamer information available."
+
+classDecls :: RenamedSource -> [LTyClDecl Name]
+classDecls (grp, _, _, _, _) =
+ [ t | t <- hs_tyclds grp
+ , isClassDecl (unLoc t) ]
+
+typeFamilyDecls :: RenamedSource -> [LTyClDecl Name]
+typeFamilyDecls (grp, _, _, _, _) =
+ [ t | t <- hs_tyclds grp
+ , isFamilyDecl (unLoc t) ]
+
+namesUsed :: TypecheckedModule -> [Name]
+namesUsed tcm = []
+

0 comments on commit 9fc53b0

Please sign in to comment.