diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bf1052822ea49a1df623eb490653d8b85a41872..0396d7e30e21124cc6704fca090b925fa4994b98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Change log for curry-frontend Under development (1.0.1) ============= + * Changed desugaring of numeric literals. It now generates calls to the + functions `Prelude.fromInt` and `Prelude.fromFloat`. * Fixed bug with wrong original names of imported record labels * Fixed bug when compiling type constructor classes with super classes diff --git a/src/Transformations/Desugar.hs b/src/Transformations/Desugar.hs index 48455efa32e0100e8071b2bc7cc9a2a640b5bb47..fa75e628b06415c0deff8260705b5e929a73ffe2 100644 --- a/src/Transformations/Desugar.hs +++ b/src/Transformations/Desugar.hs @@ -913,13 +913,13 @@ dsLiteral pty (Int i) = Right $ fixLiteral (unpredType pty) fixLiteral ty | ty == intType = Literal pty $ Int i | ty == floatType = Literal pty $ Float $ fromInteger i - | otherwise = Apply (prelFromInteger $ unpredType pty) $ + | otherwise = Apply (prelFromInt $ unpredType pty) $ Literal predIntType $ Int i dsLiteral pty f@(Float _) = Right $ fixLiteral (unpredType pty) where fixLiteral (TypeConstrained tys _) = fixLiteral (head tys) fixLiteral ty | ty == floatType = Literal pty f - | otherwise = Apply (prelFromRational $ unpredType pty) $ + | otherwise = Apply (prelFromFloat $ unpredType pty) $ Literal predFloatType f dsLiteral pty (String cs) = Left $ List pty $ map (Literal pty' . Char) cs @@ -949,11 +949,11 @@ prelBind_ ma mb = preludeFun [ma, mb] mb ">>" prelFlip :: Type -> Type -> Type -> Expression PredType prelFlip a b c = preludeFun [TypeArrow a (TypeArrow b c), b, a] c "flip" -prelFromInteger :: Type -> Expression PredType -prelFromInteger a = preludeFun [intType] a "fromInteger" +prelFromInt :: Type -> Expression PredType +prelFromInt a = preludeFun [intType] a "fromInt" -prelFromRational :: Type -> Expression PredType -prelFromRational a = preludeFun [floatType] a "fromRational" +prelFromFloat :: Type -> Expression PredType +prelFromFloat a = preludeFun [floatType] a "fromFloat" prelEnumFrom :: Type -> Expression PredType prelEnumFrom a = preludeFun [a] (listType a) "enumFrom"