diff options
author | David Waern <david.waern@gmail.com> | 2009-03-27 23:41:28 +0000 |
---|---|---|
committer | David Waern <david.waern@gmail.com> | 2009-03-27 23:41:28 +0000 |
commit | ea9a5f61a86ad667084236f048c42c7c844eb029 (patch) | |
tree | cd1aa72e6434dfb12166481a9e2063869a312b8d | |
parent | 4bd0bf841e324c7e6a716ee3e12a94e73dfaa178 (diff) |
Define Foldable and Traversable instances for Located
-rw-r--r-- | src/Haddock/GHC/Utils.hs | 31 | ||||
-rw-r--r-- | src/Haddock/Interface/Rename.hs | 8 |
2 files changed, 29 insertions, 10 deletions
diff --git a/src/Haddock/GHC/Utils.hs b/src/Haddock/GHC/Utils.hs index c0e73425..7cbcf07f 100644 --- a/src/Haddock/GHC/Utils.hs +++ b/src/Haddock/GHC/Utils.hs @@ -17,6 +17,8 @@ import Data.Char import Data.Version import qualified Data.Map as Map import Control.Arrow +import Data.Foldable hiding (concatMap) +import Data.Traversable import HsSyn import SrcLoc @@ -26,14 +28,6 @@ import Packages import Module -unL :: Located a -> a -unL (L _ x) = x - - -reL :: a -> Located a -reL = L undefined - - moduleString :: Module -> String moduleString = moduleNameString . moduleName @@ -118,6 +112,27 @@ trace_ppr x y = trace (pretty x) y ------------------------------------------------------------------------------- +-- Located +------------------------------------------------------------------------------- + + +unL :: Located a -> a +unL (L _ x) = x + + +reL :: a -> Located a +reL = L undefined + + +instance Foldable Located where + foldMap f (L _ x) = f x + + +instance Traversable Located where + mapM f (L l x) = (return . L l) =<< f x + + +------------------------------------------------------------------------------- -- NamedThing instances ------------------------------------------------------------------------------- diff --git a/src/Haddock/Interface/Rename.hs b/src/Haddock/Interface/Rename.hs index 6d806806..17fe1223 100644 --- a/src/Haddock/Interface/Rename.hs +++ b/src/Haddock/Interface/Rename.hs @@ -129,8 +129,12 @@ runRnFM env rn = unRn rn lkp -------------------------------------------------------------------------------- -rename = lookupRn id -renameL (L loc name) = return . L loc =<< rename name +rename :: Name -> RnM DocName +rename = lookupRn id + + +renameL :: Located Name -> RnM (Located DocName) +renameL = mapM rename renameExportItems :: [ExportItem Name] -> RnM [ExportItem DocName] |