Commit 393f2662 authored by batterseapower's avatar batterseapower
Browse files

Remove redundant fromIntegral calls

parent 2e065952
...@@ -7,8 +7,9 @@ module MkCore ( ...@@ -7,8 +7,9 @@ module MkCore (
mkCoreLams, mkCoreLams,
-- * Constructing boxed literals -- * Constructing boxed literals
mkWordExpr, mkWordExpr, mkWordExprWord,
mkIntExpr, mkIntegerExpr, mkIntExpr, mkIntExprInt,
mkIntegerExpr,
mkFloatExpr, mkDoubleExpr, mkFloatExpr, mkDoubleExpr,
mkCharExpr, mkStringExpr, mkStringExprFS, mkCharExpr, mkStringExpr, mkStringExprFS,
...@@ -216,12 +217,20 @@ mkCoreLams = mkLams ...@@ -216,12 +217,20 @@ mkCoreLams = mkLams
\begin{code} \begin{code}
-- | Create a 'CoreExpr' which will evaluate to the given @Int@ -- | Create a 'CoreExpr' which will evaluate to the given @Int@
mkIntExpr :: Int -> CoreExpr -- Result = I# i :: Int mkIntExpr :: Integer -> CoreExpr -- Result = I# i :: Int
mkIntExpr i = mkConApp intDataCon [mkIntLitInt i] 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@ -- | Create a 'CoreExpr' which will evaluate to the given @Word@
mkWordExpr :: Word -> CoreExpr mkWordExprWord :: Word -> CoreExpr
mkWordExpr w = mkConApp wordDataCon [mkWordLitWord w] mkWordExprWord w = mkConApp wordDataCon [mkWordLitWord w]
-- | Create a 'CoreExpr' which will evaluate to the given @Integer@ -- | Create a 'CoreExpr' which will evaluate to the given @Integer@
mkIntegerExpr :: MonadThings m => Integer -> m CoreExpr -- Result :: Integer mkIntegerExpr :: MonadThings m => Integer -> m CoreExpr -- Result :: Integer
......
...@@ -1250,7 +1250,7 @@ repNamedTyCon (MkC s) = rep2 conTName [s] ...@@ -1250,7 +1250,7 @@ repNamedTyCon (MkC s) = rep2 conTName [s]
repTupleTyCon :: Int -> DsM (Core TH.TypeQ) repTupleTyCon :: Int -> DsM (Core TH.TypeQ)
-- Note: not Core Int; it's easier to be direct here -- 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 :: DsM (Core TH.TypeQ)
repArrowTyCon = rep2 arrowTName [] repArrowTyCon = rep2 arrowTName []
...@@ -1345,7 +1345,7 @@ coreStringLit :: String -> DsM (Core String) ...@@ -1345,7 +1345,7 @@ coreStringLit :: String -> DsM (Core String)
coreStringLit s = do { z <- mkStringExpr s; return(MkC z) } coreStringLit s = do { z <- mkStringExpr s; return(MkC z) }
coreIntLit :: Int -> DsM (Core Int) 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 -> Core TH.Name -- The Id has type Name
coreVar id = MkC (Var id) coreVar id = MkC (Var id)
......
...@@ -72,7 +72,7 @@ dsLit (HsDoublePrim d) = return (Lit (MachDouble d)) ...@@ -72,7 +72,7 @@ dsLit (HsDoublePrim d) = return (Lit (MachDouble d))
dsLit (HsChar c) = return (mkCharExpr c) dsLit (HsChar c) = return (mkCharExpr c)
dsLit (HsString str) = mkStringExprFS str dsLit (HsString str) = mkStringExprFS str
dsLit (HsInteger i _) = mkIntegerExpr i dsLit (HsInteger i _) = mkIntegerExpr i
dsLit (HsInt i) = return (mkIntExpr (fromIntegral i)) dsLit (HsInt i) = return (mkIntExpr i)
dsLit (HsRat r ty) = do dsLit (HsRat r ty) = do
num <- mkIntegerExpr (numerator r) num <- mkIntegerExpr (numerator r)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment