X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectMonad.hs;h=b47da657125d222e44e338d92f81488e5d5035e3;hb=d139f68bb517f9376ae9258b008d31a133b3b906;hp=803914cc1e40c5884093d0c15cb0ef37614efece;hpb=b87a8ec229367845f28a64a371578d2b11d19ab1;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectMonad.hs b/compiler/vectorise/VectMonad.hs index 803914c..b47da65 100644 --- a/compiler/vectorise/VectMonad.hs +++ b/compiler/vectorise/VectMonad.hs @@ -1,10 +1,3 @@ -{-# 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 - module VectMonad ( Scope(..), VM, @@ -14,7 +7,8 @@ module VectMonad ( cloneName, cloneId, cloneVar, newExportedVar, newLocalVar, newDummyVar, newTyVar, - Builtins(..), sumTyCon, prodTyCon, combinePAVar, + Builtins(..), sumTyCon, prodTyCon, uarrTy, intPrimArrayTy, + combinePAVar, builtin, builtins, GlobalEnv(..), @@ -47,30 +41,23 @@ import CoreSyn import TyCon import DataCon import Type -import Class import Var import VarEnv import Id -import OccName import Name import NameEnv -import TysPrim ( intPrimTy ) -import Module -import IfaceEnv -import IOEnv ( ioToIOEnv ) +import IOEnv ( liftIO ) import DsMonad -import PrelNames import InstEnv import FamInstEnv -import Panic import Outputable import FastString import SrcLoc ( noSrcSpan ) -import Control.Monad ( liftM, zipWithM ) +import Control.Monad data Scope a b = Global a | Local b @@ -182,6 +169,7 @@ setBoxedTyConsEnv :: [(Name, TyCon)] -> GlobalEnv -> GlobalEnv setBoxedTyConsEnv ps genv = genv { global_boxed_tycons = mkNameEnv ps } +emptyLocalEnv :: LocalEnv emptyLocalEnv = LocalEnv { local_vars = emptyVarEnv , local_tyvars = [] @@ -209,7 +197,7 @@ data VResult a = Yes GlobalEnv LocalEnv a | No newtype VM a = VM { runVM :: Builtins -> GlobalEnv -> LocalEnv -> DsM (VResult a) } instance Monad VM where - return x = VM $ \bi genv lenv -> return (Yes genv lenv x) + return x = VM $ \_ genv lenv -> return (Yes genv lenv x) VM p >>= f = VM $ \bi genv lenv -> do r <- p bi genv lenv case r of @@ -242,7 +230,10 @@ orElseV p q = maybe q return =<< tryV p fixV :: (a -> VM a) -> VM a fixV f = VM (\bi genv lenv -> fixDs $ \r -> runVM (f (unYes r)) bi genv lenv ) where + -- NOTE: It is essential that we are lazy in r above so do not replace + -- calls to this function by an explicit case. unYes (Yes _ _ x) = x + unYes No = panic "VectMonad.fixV: no result" localV :: VM a -> VM a localV p = do @@ -260,7 +251,7 @@ closedV p = do return x liftDs :: DsM a -> VM a -liftDs p = VM $ \bi genv lenv -> do { x <- p; return (Yes genv lenv x) } +liftDs p = VM $ \_ genv lenv -> do { x <- p; return (Yes genv lenv x) } builtin :: (Builtins -> a) -> VM a builtin f = VM $ \bi genv lenv -> return (Yes genv lenv (f bi)) @@ -269,7 +260,7 @@ builtins :: (a -> Builtins -> b) -> VM (a -> b) builtins f = VM $ \bi genv lenv -> return (Yes genv lenv (`f` bi)) readGEnv :: (GlobalEnv -> a) -> VM a -readGEnv f = VM $ \bi genv lenv -> return (Yes genv lenv (f genv)) +readGEnv f = VM $ \_ genv lenv -> return (Yes genv lenv (f genv)) setGEnv :: GlobalEnv -> VM () setGEnv genv = VM $ \_ _ lenv -> return (Yes genv lenv ()) @@ -278,7 +269,7 @@ updGEnv :: (GlobalEnv -> GlobalEnv) -> VM () updGEnv f = VM $ \_ genv lenv -> return (Yes (f genv) lenv ()) readLEnv :: (LocalEnv -> a) -> VM a -readLEnv f = VM $ \bi genv lenv -> return (Yes genv lenv (f lenv)) +readLEnv f = VM $ \_ genv lenv -> return (Yes genv lenv (f lenv)) setLEnv :: LocalEnv -> VM () setLEnv lenv = VM $ \_ genv _ -> return (Yes genv lenv ()) @@ -286,8 +277,10 @@ setLEnv lenv = VM $ \_ genv _ -> return (Yes genv lenv ()) updLEnv :: (LocalEnv -> LocalEnv) -> VM () updLEnv f = VM $ \_ genv lenv -> return (Yes genv (f lenv) ()) +{- getInstEnv :: VM (InstEnv, InstEnv) getInstEnv = readGEnv global_inst_env +-} getFamInstEnv :: VM FamInstEnvs getFamInstEnv = readGEnv global_fam_inst_env @@ -502,7 +495,7 @@ initV hsc_env guts info p builtin_prs <- initBuiltinPRs builtins builtin_boxed <- initBuiltinBoxedTyCons builtins - eps <- ioToIOEnv $ hscEPS hsc_env + eps <- liftIO $ hscEPS hsc_env let famInstEnvs = (eps_fam_inst_env eps, mg_fam_inst_env guts) instEnvs = (eps_inst_env eps, mg_inst_env guts)