diff options
Diffstat (limited to 'compiler/codeGen')
-rw-r--r-- | compiler/codeGen/StgCmmExtCode.hs | 7 | ||||
-rw-r--r-- | compiler/codeGen/StgCmmMonad.hs | 5 |
2 files changed, 5 insertions, 7 deletions
diff --git a/compiler/codeGen/StgCmmExtCode.hs b/compiler/codeGen/StgCmmExtCode.hs index 551535d758..1d35c3454e 100644 --- a/compiler/codeGen/StgCmmExtCode.hs +++ b/compiler/codeGen/StgCmmExtCode.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE DeriveFunctor #-} -- | Our extended FCode monad. -- We add a mapping from names to CmmExpr, to support local variable names in @@ -53,7 +54,7 @@ import UniqFM import Unique import UniqSupply -import Control.Monad (liftM, ap) +import Control.Monad (ap) -- | The environment contains variable definitions or blockids. data Named @@ -73,6 +74,7 @@ type Decls = [(FastString,Named)] -- and a list of local declarations. Returns the resulting list of declarations. newtype CmmParse a = EC { unEC :: String -> Env -> Decls -> FCode (Decls, a) } + deriving (Functor) type ExtCode = CmmParse () @@ -82,9 +84,6 @@ returnExtFC a = EC $ \_ _ s -> return (s, a) thenExtFC :: CmmParse a -> (a -> CmmParse b) -> CmmParse b thenExtFC (EC m) k = EC $ \c e s -> do (s',r) <- m c e s; unEC (k r) c e s' -instance Functor CmmParse where - fmap = liftM - instance Applicative CmmParse where pure = returnExtFC (<*>) = ap diff --git a/compiler/codeGen/StgCmmMonad.hs b/compiler/codeGen/StgCmmMonad.hs index 8be5c4551f..d6f84c6a0a 100644 --- a/compiler/codeGen/StgCmmMonad.hs +++ b/compiler/codeGen/StgCmmMonad.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE GADTs #-} ----------------------------------------------------------------------------- @@ -111,9 +112,7 @@ import Data.List -------------------------------------------------------- newtype FCode a = FCode { doFCode :: CgInfoDownwards -> CgState -> (a, CgState) } - -instance Functor FCode where - fmap f (FCode g) = FCode $ \i s -> case g i s of (a, s') -> (f a, s') + deriving (Functor) instance Applicative FCode where pure val = FCode (\_info_down state -> (val, state)) |