|
1 | 1 | # purescript-partial |
2 | 2 |
|
3 | | -[](https://github.com/purescript/purescript-partial/releases) |
4 | | -[](https://travis-ci.org/purescript/purescript-partial) |
| 3 | +[](https://github.com/purescript/purescript-partial/releases) |
| 4 | +[](https://github.com/purescript/purescript-partial/actions?query=workflow%3ACI+branch%3Amaster) |
| 5 | +[](https://pursuit.purescript.org/packages/purescript-partial) |
5 | 6 |
|
6 | 7 | Utilities for working with partial functions. |
7 | 8 |
|
8 | 9 | ## Installation |
9 | 10 |
|
10 | 11 | ``` |
11 | | -bower install purescript-partial |
| 12 | +spago install partial |
12 | 13 | ``` |
13 | 14 |
|
14 | 15 | ## Why have a Partial type class? |
15 | 16 |
|
16 | | -Every now and then, you will want to use *partial functions;* that is, |
| 17 | +Every now and then, you will want to use _partial functions;_ that is, |
17 | 18 | functions which don't handle every possible case of their inputs. For example, |
18 | 19 | there is a function `fromJust :: ∀ a. Partial ⇒ Maybe a → a` in `Data.Maybe`, |
19 | 20 | which gives you the value inside a `Just` value, or throws an error if given |
20 | 21 | `Nothing`. |
21 | 22 |
|
22 | 23 | It's important that types tell the truth wherever possible, because this is a |
23 | 24 | large part of what allows us to understand PureScript code easily and refactor |
24 | | -it fearlessly. However, in certain contexts, you know that e.g. an `Either` |
| 25 | +it fearlessly. However, in certain contexts, you know that e.g. an `Either` |
25 | 26 | value is always going to be `Right`, but you can't prove that to the type |
26 | 27 | checker, and so you want an escape hatch so that you can write a function that |
27 | 28 | doesn't have to deal with the `Left` case. This is often the case when |
@@ -69,7 +70,7 @@ at src/Main.purs line 8, column 1 - line 8, column 56 |
69 | 70 | Prim.Partial |
70 | 71 | ``` |
71 | 72 |
|
72 | | -*Aside: Yes, this is not a fantastic error. It's going to get better soon.* |
| 73 | +_Aside: Yes, this is not a fantastic error. It's going to get better soon._ |
73 | 74 |
|
74 | 75 | The solution is usually to add an application of `unsafePartial` somewhere, |
75 | 76 | like this: |
@@ -172,7 +173,7 @@ Both implementations will behave in the same way. |
172 | 173 | In this case, we know our `dot` implementation is fine, and so users of it |
173 | 174 | should not have to worry about its partiality, so it makes sense to avoid |
174 | 175 | propagating the constraint. Now, we will see another case where a `Partial` |
175 | | -constraint *should* be propagated. |
| 176 | +constraint _should_ be propagated. |
176 | 177 |
|
177 | 178 | Let us suppose we want a `foldr1` function, which works in a very similar way |
178 | 179 | to `foldr` on Lists, except that it doesn't require an initial value to be |
@@ -221,4 +222,4 @@ the type system do hold. |
221 | 222 |
|
222 | 223 | ## API Documentation |
223 | 224 |
|
224 | | -* API documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial). |
| 225 | +- API documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial). |
0 commit comments