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 /src/Haddock/GHC | |
parent | 4bd0bf841e324c7e6a716ee3e12a94e73dfaa178 (diff) |
Define Foldable and Traversable instances for Located
Diffstat (limited to 'src/Haddock/GHC')
-rw-r--r-- | src/Haddock/GHC/Utils.hs | 31 |
1 files changed, 23 insertions, 8 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 ------------------------------------------------------------------------------- |