[Haskell-cafe] A question about "monad laws"
Uwe Hollerbach
uhollerbach at gmail.com
Tue Feb 12 01:18:45 EST 2008
Ratio Integer may possibly have the same trouble, or maybe something
related. I was messing around with various operators on Rationals and
found that positive and negative infinity don't compare right. Here's
a small program which shows this; if I'm doing something wrong, I'd
most appreciate it being pointed out to me. If I fire up ghci, import
Data.Ratio and GHC.Real, and then ask about the type of "infinity", it
tells me Rational, which as far as I can tell is Ratio Integer...? So
far I have only found these wrong results when I compare the two
infinities.
Uwe
> module Main where
> import Prelude
> import Data.Ratio
> import GHC.Real
>
> pinf = infinity
> ninf = -infinity
> zero = 0
>
> main =
> do putStrLn ("pinf = " ++ (show pinf))
> putStrLn ("ninf = " ++ (show ninf))
> putStrLn ("zero = " ++ (show zero))
> putStrLn ("min pinf zero =\t" ++ (show (min pinf zero)))
> putStrLn ("min ninf zero =\t" ++ (show (min ninf zero)))
> putStrLn ("min ninf pinf =\t" ++ (show (min ninf pinf)))
> putStrLn ("min pinf ninf =\t" ++ (show (min pinf ninf)) ++ "\twrong")
> putStrLn ("max pinf zero =\t" ++ (show (max pinf zero)))
> putStrLn ("max ninf zero =\t" ++ (show (max ninf zero)))
> putStrLn ("max ninf pinf =\t" ++ (show (max ninf pinf)))
> putStrLn ("max pinf ninf =\t" ++ (show (max pinf ninf)) ++ "\twrong")
> putStrLn ("(<) pinf zero =\t" ++ (show ((<) pinf zero)))
> putStrLn ("(<) ninf zero =\t" ++ (show ((<) ninf zero)))
> putStrLn ("(<) ninf pinf =\t" ++ (show ((<) ninf pinf)) ++ "\twrong")
> putStrLn ("(<) pinf ninf =\t" ++ (show ((<) pinf ninf)))
> putStrLn ("(>) pinf zero =\t" ++ (show ((>) pinf zero)))
> putStrLn ("(>) ninf zero =\t" ++ (show ((>) ninf zero)))
> putStrLn ("(>) ninf pinf =\t" ++ (show ((>) ninf pinf)))
> putStrLn ("(>) pinf ninf =\t" ++ (show ((>) pinf ninf)) ++ "\twrong")
> putStrLn ("(<=) pinf zero =\t" ++ (show ((<=) pinf zero)))
> putStrLn ("(<=) ninf zero =\t" ++ (show ((<=) ninf zero)))
> putStrLn ("(<=) ninf pinf =\t" ++ (show ((<=) ninf pinf)))
> putStrLn ("(<=) pinf ninf =\t" ++ (show ((<=) pinf ninf)) ++ "\twrong")
> putStrLn ("(>=) pinf zero =\t" ++ (show ((>=) pinf zero)))
> putStrLn ("(>=) ninf zero =\t" ++ (show ((>=) ninf zero)))
> putStrLn ("(>=) ninf pinf =\t" ++ (show ((>=) ninf pinf)))
> putStrLn ("(>=) pinf ninf =\t" ++ (show ((>=) pinf ninf)) ++ "\twrong")
More information about the Haskell-Cafe
mailing list