Commit c7df02b3 authored by Michael Hanus 's avatar Michael Hanus
Browse files

fromInteger->fromInt, fromRational->fromFloat

parent d3c7c669
...@@ -1645,7 +1645,7 @@ class Num a where ...@@ -1645,7 +1645,7 @@ class Num a where
abs :: a -> a abs :: a -> a
signum :: a -> a signum :: a -> a
fromInteger :: Int -> a fromInt :: Int -> a
x - y = x + negate y x - y = x + negate y
negate x = 0 - x negate x = 0 - x
...@@ -1664,7 +1664,7 @@ instance Num Int where ...@@ -1664,7 +1664,7 @@ instance Num Int where
| x == 0 = 0 | x == 0 = 0
| otherwise = -1 | otherwise = -1
fromInteger x = x fromInt x = x
instance Num Float where instance Num Float where
x + y = x +. y x + y = x +. y
...@@ -1681,9 +1681,9 @@ instance Num Float where ...@@ -1681,9 +1681,9 @@ instance Num Float where
| x == 0 = 0 | x == 0 = 0
| otherwise = -1 | otherwise = -1
fromInteger x = i2f x fromInt x = i2f x
-- minimal definition: fromRational and (recip or (/)) -- minimal definition: fromFloat and (recip or (/))
class Num a => Fractional a where class Num a => Fractional a where
(/) :: a -> a -> a (/) :: a -> a -> a
...@@ -1692,16 +1692,16 @@ class Num a => Fractional a where ...@@ -1692,16 +1692,16 @@ class Num a => Fractional a where
recip x = 1/x recip x = 1/x
x / y = x * recip y x / y = x * recip y
fromRational :: Float -> a -- since we have no type Rational fromFloat :: Float -> a -- since we have no type Rational
instance Fractional Float where instance Fractional Float where
x / y = x /. y x / y = x /. y
recip x = 1.0/x recip x = 1.0/x
fromRational x = x fromFloat x = x
class (Num a, Ord a) => Real a where class (Num a, Ord a) => Real a where
-- toRational :: a -> Rational -- toFloat :: a -> Float
class Real a => Integral a where class Real a => Integral a where
div :: a -> a -> a div :: a -> a -> a
......
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