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
I only fixed typos and one grammatical problem. I added clarifying punctuation in a few places. I added missing backticks for consistency (e.g. the Prelude library in line 323). I noted this line: >* `Monoid` has a superclass `Semigroup`, which provides `(<>)`, and does not require an identity. Haskell has `Semigroup` now, so you may want to indicate as much, but I didn't go ahead and make this change, myself.
Copy file name to clipboardExpand all lines: language/Differences-from-Haskell.md
+7-8
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
50
50
51
51
### Numbers
52
52
53
-
There is a native `Number` type which represents JavaScript's standard IEEE754 float and an `Int` which is restricted to the range of32bit integers.InJavaScript the `Int` values and operations are generated with a `|0` postfix to achieve this, e.g.if you have variables `x`, `y`, and`z`oftype `Int`, then the PureScript expression `(x + y) * z` would compile to `((x + y)|0* z)|0`.
53
+
There is a native `Number` type which represents JavaScript's standard IEEE754 float and an `Int` which is restricted to the range of32-bit integers.InJavaScript, the `Int` values and operations are generated with a `|0` postfix to achieve this, e.g.if you have variables `x`, `y`, and`z`oftype `Int`, then the PureScript expression `(x + y) * z` would compile to `((x + y)|0* z)|0`.
54
54
55
55
### Unit
56
56
@@ -64,7 +64,7 @@ There is also an `Array` type for native JavaScript arrays, but this does not ha
64
64
65
65
## `IO` vs `Eff`
66
66
67
-
Haskell uses the `IO` monad to deal with side effects, inPureScript there is a monad called `Eff` that serves the same purpose but can track side effects with more granularity.For example, in a Haskell program the type signature of`main` will be:
67
+
Haskell uses the `IO` monad to deal with side effects.InPureScript, there is a monad called `Eff` that serves the same purpose but can track side effects with more granularity.For example, in a Haskell program the type signature of`main` will be:
A common mistake to look out for is when writing a function that accepts a data type like the original `Point` above, is that the object is still wrapped inside `Point` so something like this will fail:
126
+
A common mistake to look out for is when writing a function that accepts a data type like the original `Point` above—the object is still wrapped inside `Point`, so something like this will fail:
127
127
128
128
```purescript
129
129
showPoint :: Point -> String
130
130
showPoint p = show p.x <> ", " <> show p.y
131
131
```
132
132
133
-
Instead we need to destructure `Point` to get at the object:
133
+
Instead, we need to destructure `Point` to get at the object:
134
134
135
135
```purescript
136
136
showPoint :: Point -> String
@@ -199,7 +199,7 @@ When instances cannot be declared in the same module, one way to work around it
199
199
200
200
### Default members
201
201
202
-
At the moment it is not possible to declare default member implementations for type classes. This may change in the future.
202
+
At the moment, it is not possible to declare default member implementations for type classes. This may change in the future.
203
203
204
204
### Type class hierarchies
205
205
@@ -223,7 +223,7 @@ The `<<<` operator is actually a more general morphism composition operator that
223
223
224
224
## `return`
225
225
226
-
In the past, PureScript used `return`. However, it is now removed and replaced with [`pure`](https://pursuit.purescript.org/packages/purescript-prelude/1.1.0/docs/Control.Applicative#v:pure). It was always an alias for pure, which means this change was implemented by simply removing the alias.
226
+
In the past, PureScript used `return`. However, it is now removed and replaced with [`pure`](https://pursuit.purescript.org/packages/purescript-prelude/1.1.0/docs/Control.Applicative#v:pure). It was always an alias for `pure`, which means this change was implemented by simply removing the alias.
227
227
228
228
## Array Comprehensions
229
229
@@ -320,10 +320,9 @@ When writing documentation, the pipe character `|` must appear at the start of e
320
320
As PureScript has not inherited Haskell's legacy code, some operators and functions that are common in Haskell have different names in PureScript:
321
321
322
322
-`(>>)` is `(*>)`, as `Apply` is a superclass of `Monad` so there is no need to have an `Monad`-specialised version.
323
-
- Since 0.9.1, the Prelude library does not contain `(++)` as a second alias for `append` / `(<>)` (`mappend` in Haskell) anymore.
323
+
- Since 0.9.1, the `Prelude` library does not contain `(++)` as a second alias for `append` / `(<>)` (`mappend` in Haskell) anymore.
324
324
-`mapM` is `traverse`, as this is a more general form that applies to any traversable structure, not just lists. Also it only requires `Applicative` rather than `Monad`. Similarly, `liftM` is `map`.
325
325
- Many functions that are part of `Data.List` in Haskell are provided in a more generic form in `Data.Foldable` or `Data.Traversable`.
326
326
-`some` and `many` are defined with the type of list they operate on (`Data.Array` or `Data.List`).
327
327
- Instead of `_foo` for typed holes, use `?foo`. You have to name the hole; `?` is not allowed.
328
328
- Ranges are written as `1..2` rather than `[1..2]`
0 commit comments