You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: language/Differences-from-Haskell.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -267,6 +267,45 @@ In PureScript, operator sections look a little bit different.
267
267
(_ ^ 2)
268
268
```
269
269
270
+
## Fixity declarations for functions
271
+
272
+
In Haskell, functions can have fixity declarations. For example in `base`:
273
+
274
+
```haskell
275
+
infix4`elem`, `notElem`
276
+
infixl7`quot`, `rem`, `div`, `mod`
277
+
```
278
+
279
+
However fixity declarations are only supported while declaring [operator aliases](Syntax.md#binary-operators) for functions in PureScript. Functions are always left associative and have the highest precedence when used as infix operators, which means that:
280
+
281
+
```
282
+
x * y `mod` z
283
+
```
284
+
285
+
parses as:
286
+
287
+
```haskell
288
+
((x * y) `mod` z)
289
+
```
290
+
291
+
in Haskell, but as:
292
+
293
+
```purescript
294
+
(x * (y `mod` z))
295
+
```
296
+
297
+
in PureScript, and those expressions may yield different values:
298
+
299
+
```purescript
300
+
> ((2 * 3) `mod` 5)
301
+
1
302
+
```
303
+
304
+
```purescript
305
+
> (2 * (3 `mod` 5))
306
+
6
307
+
```
308
+
270
309
## Extensions
271
310
272
311
The PureScript compiler does not support GHC-like language extensions. However, there are some "built-in" language features that are equivalent (or at least similar) to a number of GHC extensions. These currently are:
0 commit comments