[Haskell-beginners] wierd quickcheck outcome

Kim-Ee Yeoh ky3 at atamo.com
Thu Sep 10 09:25:03 UTC 2015


Hi Roelof,

> False == True && False
False

> False == (True && False)
True

> :info (==)
class Eq a where
  (==) :: a -> a -> Bool
infix 4 ==

> :info (&&)
(&&) :: Bool -> Bool -> Bool
infixr 3 &&

So (==) at level 4 binds tighter than (&&) at level 3.

See: https://www.haskell.org/onlinereport/decls.html#fixity

-- Kim-Ee

On Thu, Sep 10, 2015 at 2:23 PM, Roelof Wobben <r.wobben at home.nl> wrote:

> Hello,
>
> I have this function :
>
> fourDifferent:: Integer -> Integer -> Integer -> Integer -> Bool
> fourDifferent a b c d = ( a == b ) && ( a == c ) && (a == d)
>
> which I wants to test with this function :
>
> prop_fourDifferent :: Integer -> Integer -> Integer -> Integer -> Bool
> prop_fourDifferent a b c d = fourDifferent a b c d == ( a == b ) && ( a ==
> c ) && (a == d)
>
> so I do quickCheck propFourDifferent and see this outcome :
>
> *Solution> quickCheck prop_fourDifferent
> *** Failed! Falsifiable (after 2 tests and 2 shrinks):
> 0
> 0
> 0
> 1
>
> *Solution> fourDifferent 0 0 0 1
> False
> *Solution> let a = 0
> *Solution> let b = 0
> *Solution> let c = 0
> *Solution> let d = 1
> *Solution> (a == b) && ( a == c) && ( a == d ) False
> *Solution>
>
>
> So why is it failing. both gives false ,
>
> Roelof
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150910/92c7081f/attachment.html>


More information about the Beginners mailing list