Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor issues #454

Merged
merged 2 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion text/chapter1.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ This book aims to provide an introduction to the PureScript language for beginne
If you get stuck at any point, there are a number of resources available online for learning PureScript:

- The [PureScript Discord server](https://discord.gg/vKn9up84bp) is a great place to chat about issues you may be having. The server is dedicated to chatting about PureScript
- The [Purescript Discourse Forum](https://discourse.purescript.org/) is another good place to search for solutions to common problems.
- The [PureScript Discourse Forum](https://discourse.purescript.org/) is another good place to search for solutions to common problems.
- [PureScript: Jordan's Reference](https://github.com/jordanmartinez/purescript-jordans-reference) is an alternative learning resource that goes into great depth. If a concept in this book is difficult to understand, consider reading the corresponding section in that reference.
- [Pursuit](https://pursuit.purescript.org) is a searchable database of PureScript types and functions. Read Pursuit's help page to [learn what kinds of searches you can do](https://pursuit.purescript.org/help/users).
- The unofficial [PureScript Cookbook](https://github.com/JordanMartinez/purescript-cookbook) provides answers via code to "How do I do X?"-type questions.
Expand Down
4 changes: 2 additions & 2 deletions text/chapter10.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ We can assign this type to the function with the following foreign import declar
{{#include ../exercises/chapter10/test/URI.purs}}
```

We also need to write a foreign JavaScript module to import it from. A corresponding foreign JavaScript module is one of the same name but the extension changed from `.purs` to `.js`. If the Purescript module above is saved as `URI.purs`, then the foreign JavaScript module is saved as `URI.js`.
We also need to write a foreign JavaScript module to import it from. A corresponding foreign JavaScript module is one of the same name but the extension changed from `.purs` to `.js`. If the PureScript module above is saved as `URI.purs`, then the foreign JavaScript module is saved as `URI.js`.
Since `encodeURIComponent` is already defined, we have to export it as `_encodeURIComponent`:

```javascript
{{#include ../exercises/chapter10/test/URI.js}}
```

Since version 0.15, Purescript uses the ES module system when interoperating with JavaScript. In ES modules, functions and values are exported from a module by providing the `export` keyword on an object.
Since version 0.15, PureScript uses the ES module system when interoperating with JavaScript. In ES modules, functions and values are exported from a module by providing the `export` keyword on an object.

With these two pieces in place, we can now use the `_encodeURIComponent` function from PureScript like any function written in PureScript. For example, in PSCi, we can reproduce the calculation above:

Expand Down
2 changes: 1 addition & 1 deletion text/chapter11.md
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ The final piece of the application is responsible for parsing command line optio
`optparse` is an example of _applicative command line option parsing_. Recall that an applicative functor allows us to lift functions of arbitrary arity over a type constructor representing some type of side-effect. In the case of the `optparse` package, the functor we are interested in is the `Parser` functor (imported from the optparse module `Options.Applicative`, not to be confused with our `Parser` that we defined in the `Split` module), which adds the side-effect of reading from command line options. It provides the following handler:

```haskell
customExecParser :: forall a. ParserPrefs ParserInfo a Effect a
customExecParser :: forall a. ParserPrefs -> ParserInfo a -> Effect a
```

This is best illustrated by example. The application's `main` function is defined using `customExecParser` as follows:
Expand Down
4 changes: 2 additions & 2 deletions text/chapter12.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type Rectangle =
}
```

The `x` and `y` properties represent the location of the top-left corner, while the `w` and `h` properties represent the width and height, respectively.
The `x` and `y` properties represent the location of the top-left corner, while the `width` and `height` properties represent the lengths of the rectangle, respectively.

To render an arc segment, we can use the `arc` function, passing a record with the following type:

Expand All @@ -100,7 +100,7 @@ type Arc =
}
```

Here, the `x` and `y` properties represent the center point, `r` is the radius, `start` and `end` represent the endpoints of the arc in radians.
Here, the `x` and `y` properties represent the center point, `radius` is the radius, `start` and `end` represent the endpoints of the arc in radians.

For example, this code fills an arc segment centered at `(300, 300)` with radius `50`. The arc completes 2/3rds of a rotation. Note that the unit circle is flipped vertically since the y-axis increases towards the bottom of the canvas:

Expand Down
2 changes: 1 addition & 1 deletion text/chapter3.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ For illustration purposes, let's define a primitive function that takes any two

The keyword `forall` indicates that `constantlyFirst` has a _universally quantified type_. It means we can substitute any types for `a` and `b` – `constantlyFirst` will work with these types.

For example, we might choose the type `a` to be `Int` and `b` `String`. In that case, we can _specialize_ the type of `constantlyFirst` to
For example, we might choose the type `a` to be `Int` and `b` to be `String`. In that case, we can _specialize_ the type of `constantlyFirst` to

```text
Int -> String -> Int
Expand Down
2 changes: 1 addition & 1 deletion text/chapter6.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ Another reason to define a superclass relationship is when there is a clear "is-

Remember, your instance must satisfy the laws listed above.

1. (Difficult) There are multiple ways to implement an instance of `Action Multiply Int`. How many can you think of? Purescript does not allow multiple implementations of the same instance, so you will have to replace your original implementation. _Note_: the tests cover 4 implementations.
1. (Difficult) There are multiple ways to implement an instance of `Action Multiply Int`. How many can you think of? PureScript does not allow multiple implementations of the same instance, so you will have to replace your original implementation. _Note_: the tests cover 4 implementations.

1. (Medium) Write an `Action` instance that repeats an input string some number of times:

Expand Down
4 changes: 2 additions & 2 deletions text/chapter7.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ Or with _applicative do_:
Maybe String -> Maybe String -> Maybe String -> Either String String
```

Now our function takes three optional arguments using `Maybe, and returns either a`String` error message or a `String` result.
Now our function takes three optional arguments using `Maybe`, and returns either a`String` error message or a `String` result.
Zelenya marked this conversation as resolved.
Show resolved Hide resolved

We can try out the function with different inputs:

Expand Down Expand Up @@ -696,6 +696,6 @@ In this chapter, we covered a lot of new ideas:
- We saw how applicative functors solved the problem of validating data structures and how by switching the applicative functor, we could change from reporting a single error to reporting all errors across a data structure.
- We met the `Traversable` type class, which encapsulates the idea of a _traversable functor_, or a container whose elements can be used to combine values with side-effects.

Applicative functors are an interesting abstraction that provides neat solutions to a number of problems. We will see them a few more times throughout the book. In this case, the validation applicative functor provided a way to write validators in a declarative style, allowing us to define _what_ our validators should validate and not _how_ they should perform that validation. In general, we will see that applicative functors are a useful tool for the design of _domain specific languages.
Applicative functors are an interesting abstraction that provides neat solutions to a number of problems. We will see them a few more times throughout the book. In this case, the validation applicative functor provided a way to write validators in a declarative style, allowing us to define _what_ our validators should validate and not _how_ they should perform that validation. In general, we will see that applicative functors are a useful tool for the design of _domain specific languages_.

In the next chapter, we will see a related idea, the class of _monads_, and extend our address book example to run in the browser!
Loading