From ea9a5f61a86ad667084236f048c42c7c844eb029 Mon Sep 17 00:00:00 2001 From: David Waern Date: Fri, 27 Mar 2009 23:41:28 +0000 Subject: Define Foldable and Traversable instances for Located --- src/Haddock/GHC/Utils.hs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src/Haddock/GHC') 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 @@ -117,6 +111,27 @@ trace_ppr :: Outputable a => a -> b -> b 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 ------------------------------------------------------------------------------- -- cgit v1.2.3