What is and what is this infixr 3 & & amp;
infixr 3 &&
(&&) :: Bool -> Bool -> Bool
True && True = True
_ && _ = False
What is and what is this infixr 3 & & amp;
infixr 3 &&
(&&) :: Bool -> Bool -> Bool
True && True = True
_ && _ = False
Infixed notation means that the operator comes between the operands, for example 1 + 1
. Functions in haskell generally use postfixed notation, such as pow 1 2
.
r
or l
refers to associativity, r
to right associativity
In your example True && True && True
will be interpreted as True && (True && True)
The number refers to precedence, the greater the number, the greater the precedence.