The difference between Haskell ((<x) y) and (((<) x) y)

I can’t wrap my head around why they will 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 is a direct answer, but I don’t even know which words to use to describe the difference between the first and second cases. I am happy to change my question to use the correct nomenclature as soon as someone tells me that this is the case.

+4
source share
1 answer

(<) 3applies 3as the first (left) argument <. So, (<) 3 2coincides with 3 < 2.

(< 3) section, 3 <. , . , (< 3) 2 2 < 3.

3 , : (3 <). , (3 <) 2 3 < 2.

lambdas: (< 3) \x -> x < 3, (3 <) \x -> 3 < x.

+9

Source: https://habr.com/ru/post/1684032/


All Articles