arliss_obsidian/fp/Language/Infix Operators/Defining.md
Orion Kindel 3701b1e2f8
update
2024-09-23 18:56:55 -05:00

358 B

Infix Operators are defined with the keyword infix, infixl or infixr.

infix <precedence> <fn> as <operator>
-- or
infixl -- ..
-- or
infixr -- ..

e.g.

eq :: Int -> Int -> Boolean
eq = -- ...

add :: Int -> Int -> Int
add = -- ...

infixl 2 add as +
infixl 1 eq as ==

1 + 2 == 3
-- same as
(eq (add 1 2) 3)