From 393f26621b762225b204b3dc78b05a3ecf08871e Mon Sep 17 00:00:00 2001 From: Max Bolingbroke Date: Thu, 7 Aug 2008 22:43:33 +0000 Subject: [PATCH] Remove redundant fromIntegral calls --- compiler/coreSyn/MkCore.lhs | 21 +++++++++++++++------ compiler/deSugar/DsMeta.hs | 4 ++-- compiler/deSugar/MatchLit.lhs | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/compiler/coreSyn/MkCore.lhs b/compiler/coreSyn/MkCore.lhs index b930f88..0844a0a 100644 --- a/compiler/coreSyn/MkCore.lhs +++ b/compiler/coreSyn/MkCore.lhs @@ -7,8 +7,9 @@ module MkCore ( mkCoreLams, -- * Constructing boxed literals - mkWordExpr, - mkIntExpr, mkIntegerExpr, + mkWordExpr, mkWordExprWord, + mkIntExpr, mkIntExprInt, + mkIntegerExpr, mkFloatExpr, mkDoubleExpr, mkCharExpr, mkStringExpr, mkStringExprFS, @@ -216,12 +217,20 @@ mkCoreLams = mkLams \begin{code} -- | Create a 'CoreExpr' which will evaluate to the given @Int@ -mkIntExpr :: Int -> CoreExpr -- Result = I# i :: Int -mkIntExpr i = mkConApp intDataCon [mkIntLitInt i] +mkIntExpr :: Integer -> CoreExpr -- Result = I# i :: Int +mkIntExpr i = mkConApp intDataCon [mkIntLit i] + +-- | Create a 'CoreExpr' which will evaluate to the given @Int@ +mkIntExprInt :: Int -> CoreExpr -- Result = I# i :: Int +mkIntExprInt i = mkConApp intDataCon [mkIntLitInt i] + +-- | Create a 'CoreExpr' which will evaluate to the a @Word@ with the given value +mkWordExpr :: Integer -> CoreExpr +mkWordExpr w = mkConApp wordDataCon [mkWordLit w] -- | Create a 'CoreExpr' which will evaluate to the given @Word@ -mkWordExpr :: Word -> CoreExpr -mkWordExpr w = mkConApp wordDataCon [mkWordLitWord w] +mkWordExprWord :: Word -> CoreExpr +mkWordExprWord w = mkConApp wordDataCon [mkWordLitWord w] -- | Create a 'CoreExpr' which will evaluate to the given @Integer@ mkIntegerExpr :: MonadThings m => Integer -> m CoreExpr -- Result :: Integer diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs index 6cc1eee..3659498 100644 --- a/compiler/deSugar/DsMeta.hs +++ b/compiler/deSugar/DsMeta.hs @@ -1250,7 +1250,7 @@ repNamedTyCon (MkC s) = rep2 conTName [s] repTupleTyCon :: Int -> DsM (Core TH.TypeQ) -- Note: not Core Int; it's easier to be direct here -repTupleTyCon i = rep2 tupleTName [mkIntExpr (fromIntegral i)] +repTupleTyCon i = rep2 tupleTName [mkIntExprInt i] repArrowTyCon :: DsM (Core TH.TypeQ) repArrowTyCon = rep2 arrowTName [] @@ -1345,7 +1345,7 @@ coreStringLit :: String -> DsM (Core String) coreStringLit s = do { z <- mkStringExpr s; return(MkC z) } coreIntLit :: Int -> DsM (Core Int) -coreIntLit i = return (MkC (mkIntExpr (fromIntegral i))) +coreIntLit i = return (MkC (mkIntExprInt i)) coreVar :: Id -> Core TH.Name -- The Id has type Name coreVar id = MkC (Var id) diff --git a/compiler/deSugar/MatchLit.lhs b/compiler/deSugar/MatchLit.lhs index b6079d3..5e30f32 100644 --- a/compiler/deSugar/MatchLit.lhs +++ b/compiler/deSugar/MatchLit.lhs @@ -72,7 +72,7 @@ dsLit (HsDoublePrim d) = return (Lit (MachDouble d)) dsLit (HsChar c) = return (mkCharExpr c) dsLit (HsString str) = mkStringExprFS str dsLit (HsInteger i _) = mkIntegerExpr i -dsLit (HsInt i) = return (mkIntExpr (fromIntegral i)) +dsLit (HsInt i) = return (mkIntExpr i) dsLit (HsRat r ty) = do num <- mkIntegerExpr (numerator r) -- 1.7.10.4