summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/RegAlloc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/nativeGen/RegAlloc')
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/State.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/nativeGen/RegAlloc/Linear/State.hs b/compiler/nativeGen/RegAlloc/Linear/State.hs
index a608a947e7..dc499c9c1f 100644
--- a/compiler/nativeGen/RegAlloc/Linear/State.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/State.hs
@@ -40,13 +40,21 @@ import DynFlags
import Unique
import UniqSupply
+import Control.Monad (liftM, ap)
+import Control.Applicative (Applicative(..))
+
-- | The register allocator monad type.
newtype RegM freeRegs a
= RegM { unReg :: RA_State freeRegs -> (# RA_State freeRegs, a #) }
+instance Functor (RegM freeRegs) where
+ fmap = liftM
+
+instance Applicative (RegM freeRegs) where
+ pure = return
+ (<*>) = ap
--- | The RegM Monad
instance Monad (RegM freeRegs) where
m >>= k = RegM $ \s -> case unReg m s of { (# s, a #) -> unReg (k a) s }
return a = RegM $ \s -> (# s, a #)