aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GHCUtils.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/GHCUtils.hs b/src/GHCUtils.hs
new file mode 100644
index 00000000..b5448dd4
--- /dev/null
+++ b/src/GHCUtils.hs
@@ -0,0 +1,15 @@
+module GHCUtils where
+
+import HsSyn
+import SrcLoc
+
+getMainDeclBinder :: HsDecl name -> Maybe name
+getMainDeclBinder (TyClD d) = Just (tcdName d)
+getMainDeclBinder (ValD d)
+ = case collectAcc d [] of
+ [] -> Nothing -- see rn003
+ (name:_) -> Just (unLoc name)
+getMainDeclBinder (SigD d) = sigNameNoLoc d
+getMainDeclBinder (ForD (ForeignImport name _ _)) = Just (unLoc name)
+getMainDeclBinder (ForD (ForeignExport name _ _)) = Just (unLoc name)
+getMainDeclBinder _ = Nothing