forked from orion/obsidian
25 lines
358 B
Markdown
25 lines
358 B
Markdown
[[Infix Operators|Operators]] are defined with the keyword `infix`, `infixl` or `infixr`.
|
|
|
|
```haskell
|
|
infix <precedence> <fn> as <operator>
|
|
-- or
|
|
infixl -- ..
|
|
-- or
|
|
infixr -- ..
|
|
```
|
|
|
|
e.g.
|
|
```haskell
|
|
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)
|
|
``` |