aboutsummaryrefslogtreecommitdiff
path: root/src/GHCUtils.hs
blob: 01bc89f45fb1baf67ccdb9af75c3ac78022a4608 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 _ _)) = Nothing
getMainDeclBinder _ = Nothing