Commits

Paweł Wieczorek committed deccba2

deriving instances Monad, MonadState for Compiler

  • Participants
  • Parent commits 45646ad

Comments (0)

Files changed (1)

src/Selen/Compiler/CPS/Monad.hs

 
 -- bad design, problem with overlapping instances TransformationMonad (StateT s m)
 newtype Compiler a = MkCompiler (StateT CompilerState (FreshT IO) a)
-
-instance Monad Compiler where
-    return x   = MkCompiler (return x)
-    fail   x   = MkCompiler (fail x)
-    -- Compiler a -> (b -> Compiler b) -> Compiler b
-    (MkCompiler m) >>= f = MkCompiler $ do
-        x <- m
-        let (MkCompiler m') = f x
-        m'
-
-instance MonadState CompilerState Compiler where
-    put = undefined
-    get = undefined
-
+    deriving (Monad, MonadState CompilerState)
 
 runCompiler :: Int -> Compiler a -> IO a
 runCompiler s (MkCompiler m) = do