X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FUtils%2FHsTools.hs;h=c08bad7b4fe1a0b133957cee6addf91c359d1eb9;hb=f3951a1376fc7d7f8addbe9e9fed071320502100;hp=ca20441cc706a360b17cc1b53c40fff89fde77a2;hpb=eab16fafe7a623b5ea669023b91ddee4b1983526;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git "a/c\316\273ash/CLasH/Utils/HsTools.hs" "b/c\316\273ash/CLasH/Utils/HsTools.hs" index ca20441..c08bad7 100644 --- "a/c\316\273ash/CLasH/Utils/HsTools.hs" +++ "b/c\316\273ash/CLasH/Utils/HsTools.hs" @@ -1,4 +1,3 @@ -{-# LANGUAGE ViewPatterns #-} module CLasH.Utils.HsTools where -- Standard modules @@ -33,29 +32,20 @@ import qualified TcEnv import qualified TcSimplify import qualified TcTyFuns import qualified Desugar -import qualified InstEnv -import qualified FamInstEnv import qualified PrelNames import qualified Module import qualified OccName import qualified RdrName import qualified Name -import qualified TysWiredIn import qualified SrcLoc import qualified LoadIface import qualified BasicTypes -import qualified Bag -- Core representation and handling import qualified CoreSyn import qualified Id import qualified Type import qualified TyCon - --- Local imports -import CLasH.Utils.GhcTools -import CLasH.Utils.Core.CoreShow - -- | Translate a HsExpr to a Core expression. This does renaming, type -- checking, simplification of class instances and desugaring. The result is -- a let expression that holds the given expression and a number of binds that @@ -96,15 +86,14 @@ toCore expr = do tc_expr -- Desugar the expression, resulting in core. let rdr_env = HscTypes.ic_rn_gbl_env icontext - desugar_expr <- HscTypes.ioMsgMaybe $ Desugar.deSugarExpr env PrelNames.iNTERACTIVE rdr_env HscTypes.emptyTypeEnv letexpr + HscTypes.ioMsgMaybe $ Desugar.deSugarExpr env PrelNames.iNTERACTIVE rdr_env HscTypes.emptyTypeEnv letexpr - return desugar_expr -- | Create an Id from a RdrName. Might not work for DataCons... mkId :: RdrName.RdrName -> GHC.Ghc Id.Id mkId rdr_name = do env <- GHC.getSession - id <- HscTypes.ioMsgMaybe $ MonadUtils.liftIO $ + HscTypes.ioMsgMaybe $ MonadUtils.liftIO $ -- Translage the TcRn (typecheck-rename) monad in an IO monad TcRnMonad.initTcPrintErrors env PrelNames.iNTERACTIVE $ -- Automatically import all available modules, so fully qualified names @@ -119,7 +108,6 @@ mkId rdr_name = do -- Note that tcLookupId doesn't seem to work for DataCons. See source for -- tcLookupId to find out. TcEnv.tcLookupId name - return id normaliseType :: HscTypes.HscEnv @@ -147,7 +135,7 @@ coreToHsType ty = case Type.splitTyConApp_maybe ty of occ_name = Name.nameOccName tycon_name tycon_rdrname = RdrName.mkRdrQual mod_name occ_name tycon_ty = SrcLoc.noLoc $ HsTypes.HsTyVar tycon_rdrname - Nothing -> error $ "HsTools.coreToHsType Cannot translate non-tycon type" + Nothing -> error "HsTools.coreToHsType Cannot translate non-tycon type" -- | Evaluate a CoreExpr and return its value. For this to work, the caller -- should already know the result type for sure, since the result value is