X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FInst.lhs;h=0c18a014bc225577bcbcb2d966488a6e617369e5;hb=11db0bc8cd2eee13339578ca447c0a2d97f453c3;hp=b1636a7e221851338f6e1ac9db14614f3c165d38;hpb=c51a0666f41b91ed6b8cad334eb54e7f01560d32;p=ghc-hetmet.git diff --git a/compiler/typecheck/Inst.lhs b/compiler/typecheck/Inst.lhs index b1636a7..0c18a01 100644 --- a/compiler/typecheck/Inst.lhs +++ b/compiler/typecheck/Inst.lhs @@ -474,6 +474,7 @@ newMethod inst_loc id tys = do shortCutIntLit :: Integer -> TcType -> Maybe (HsExpr TcId) shortCutIntLit i ty | isIntTy ty && inIntRange i = Just (HsLit (HsInt i)) + | isWordTy ty && inWordRange i = Just (mkLit wordDataCon (HsWordPrim i)) | isIntegerTy ty = Just (HsLit (HsInteger i ty)) | otherwise = shortCutFracLit (fromInteger i) ty -- The 'otherwise' case is important @@ -484,11 +485,13 @@ shortCutIntLit i ty shortCutFracLit :: Rational -> TcType -> Maybe (HsExpr TcId) shortCutFracLit f ty - | isFloatTy ty = Just (mk_lit floatDataCon (HsFloatPrim f)) - | isDoubleTy ty = Just (mk_lit doubleDataCon (HsDoublePrim f)) + | isFloatTy ty = Just (mkLit floatDataCon (HsFloatPrim f)) + | isDoubleTy ty = Just (mkLit doubleDataCon (HsDoublePrim f)) | otherwise = Nothing where - mk_lit con lit = HsApp (nlHsVar (dataConWrapId con)) (nlHsLit lit) + +mkLit :: DataCon -> HsLit -> HsExpr Id +mkLit con lit = HsApp (nlHsVar (dataConWrapId con)) (nlHsLit lit) shortCutStringLit :: FastString -> TcType -> Maybe (HsExpr TcId) shortCutStringLit s ty