Strange behavior for priority infix functions

I am using a function bool :: a -> a -> Bool -> a

. I wanted to use the infix version because I, although it is more readable, but I noticed that:

(-1) `bool` 1 True

      

- mistake

(-1) `bool` 1 $ True

      

works. Even

(-1) `bool` 1 (True)

      

does not work and I have considered it an equal alternative so far (i.e. using $

versus packing in parentheses from this location to the end)

How can this change? The first version only has one operation.

+3


source to share


1 answer


Infix operators are loosely bound, applications are hard bound.

(-1) `bool` 1 True
-- means
(-1) `bool` (1 True)


(-1) `bool` 1 $ True
-- means
((-1) `bool` 1) $ True


(-1) `bool` 1 (True)
-- means
(-1) `bool` (1 (True))

      



You might want to:

((-1) `bool` 1) True

      

+4


source







All Articles