Make compileToCore return the module name and type environment along with bindings
[ghc-hetmet.git] / compiler / utils / IOEnv.hs
index c0277ae..fc513a0 100644 (file)
@@ -1,3 +1,10 @@
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
+
 --
 -- (c) The University of Glasgow 2002-2006
 --
@@ -47,6 +54,9 @@ instance Monad (IOEnv m) where
   return = returnM
   fail s = failM       -- Ignore the string
 
+instance Functor (IOEnv m) where
+  fmap f (IOEnv m) = IOEnv (\ env -> fmap f (m env))
+
 returnM :: a -> IOEnv env a
 returnM a = IOEnv (\ env -> return a)
 
@@ -89,7 +99,9 @@ fixM f = IOEnv (\ env -> fixIO (\ r -> unIOEnv (f r) env))
 
 ---------------------------
 tryM :: IOEnv env r -> IOEnv env (Either Exception r)
--- Reflect UserError exceptions into IOEnv monad
+-- Reflect UserError exceptions (only) into IOEnv monad
+-- Other exceptions are not caught; they are simply propagated as exns
+--
 -- The idea is that errors in the program being compiled will give rise
 -- to UserErrors.  But, say, pattern-match failures in GHC itself should
 -- not be caught here, else they'll be reported as errors in the program