I am reading Learn You a Haskell, which contains 5 /= 5
. I am not so sure what this means. Does the first expression mean 5 / 5 = 5
? But, then, it shouldn't be True
.
Haskell provides special syntax to support infix notation. An operator is a function that can be applied using infix syntax (Section 3.4), or partially applied using a section (Section 3.5).
The == is an operator for comparing if two things are equal. It is quite normal haskell function with type "Eq a => a -> a -> Bool". The type tells that it works on every type of a value that implements Eq typeclass, so it is kind of overloaded.
'/=': This is the basic representation of the not equal operator in Haskell, also it is an inbuilt feature provided by the Haskell language, so we do not require to include any library or external dependency for this to use this in the program.
We can also compare two numerical values to see which one is larger. Haskell provides a number of tests including: < (less than), > (greater than), <= (less than or equal to) and >= (greater than or equal to). These tests work comparably to == (equal to).
It means not equal. So 5 /= 5
is false as 5 == 5
is true.
x /= y = not (x == y)
As suggested, it recalls the mathematical symbol "≠" (/=) opposite to "=" (==).
The ==
operator means "is equal".
The /=
operator means "is not equal".
It's supposed to be reminiscent of the mathematical "≠" symbol (i.e., an equals sign with a diagonal line through it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With