I can't wrap my head around why these would be different.:
Prelude> :t ((<) 3)
((<) 3) :: (Num a, Ord a) => a -> Bool
Prelude> ((<) 3) 2
False
Prelude>
Prelude> :t (< 3)
(< 3) :: (Num a, Ord a) => a -> Bool
Prelude> (< 3) 2
True
Prelude>
I suspect there's a straightforward answer, but I don't even know what words to use to describe the difference between the first and second cases. I'm happy to edit my question to use proper nomenclature once someone tells me what it is in this case.
(<) 3
applies 3
as the first (left) argument of <
. So (<) 3 2
is the same as 3 < 2
.
(< 3)
is a section that applies 3
as the right operand of <
. This is special syntax that can be used with binary infix operators. So (< 3) 2
is the same as 2 < 3
.
To apply 3
as the left operand with a section, you would write: (3 <)
. So (3 <) 2
is the same as 3 < 2
.
Demonstrating with lambdas: (< 3)
is the same as \x -> x < 3
, and (3 <)
is the same as \x -> 3 < x
.
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