Skip to content

Commit

Permalink
(docs) Fix small typos (#2152)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenranunderscore committed Mar 11, 2024
1 parent 3c94ea2 commit 762cdf3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions data/tutorials/getting-started/1_01_a_tour_of_ocaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Lists may be the most common data type in OCaml. They are ordered collections of
- : int list list = [[1; 2]; [3]; [4; 5; 6]]
```

The example above read the following way:
The examples above read the following way:
1. The empty list, nil
1. A list containing the numbers 1, 2, and 3
1. A list containing the Booleans `false`, `true`, and `false`. Repetitions are allowed.
Expand Down Expand Up @@ -449,7 +449,7 @@ Tuples are fixed-length collections of elements of any type. Pairs are tuples th
- : 'a list * bool = ([], false)
```

Access to the component of tuple is done using pattern matching. For instance, the predefined function `snd` returns the second component of a pair:
Access to the components of tuples is done using pattern matching. For instance, the predefined function `snd` returns the second component of a pair:
```ocaml
# let snd p =
match p with
Expand All @@ -464,7 +464,7 @@ Note: The function `snd` is predefined in the OCaml standard library.

The type of tuples is written using `*` between the components' types.

### Variants Types
### Variant Types

Like pattern matching generalises `switch` statements, variant types generalise enumerated and union types.

Expand Down Expand Up @@ -731,7 +731,7 @@ Definitions provided by modules are referred to by adding the module name as a p
```

Here, usage of the function `Option.map` is illustrated in several steps.
1. Display its type. It has two parameters. A function of type `'a -> 'b` and an `'a option`.
1. Display its type. It has two parameters: a function of type `'a -> 'b` and an `'a option`.
1. Using partial application, only pass `fun x -> x * x`. Check the type of the resulting function.
1. Apply with `None`.
1. Apply with `Some 8`.
Expand All @@ -749,7 +749,7 @@ The `List.map` function which was used earlier in this section is also part of a

This illustrates the first feature of the OCaml module system. It provides a means to separate concerns by preventing name clashes. Two functions having different type may have the same name if they are provided by different modules.

Module also allows efficient separated compilation. This is illustrated in the next tutorial.
Modules also allow for efficient separate compilation. This is illustrated in the next tutorial.

## Conclusion

Expand Down
2 changes: 1 addition & 1 deletion data/tutorials/language/1ms_01_functors.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Here is how this reads (starting from the bottom, then going up):
- returns a module with signature [`Set.S`](/api/Set.S.html)
* The module type `OrderedType` requires a type `t` and a function `compare`, which are used to perform the comparisons between elements of the set.

**Note**: Most set operations need to compare elements to check if they are the same. To allow using a user-defined comparison algorithm, the `Set.Make` functor takes a module the specifies both the element type `t` and the `compare` function. Passing the comparison function as a higher-order parameter, as done in `Array.sort`, for example, would add a lot of boilerplate code. Providing set operations as a functor allows specifying the comparison function only once.
**Note**: Most set operations need to compare elements to check if they are the same. To allow using a user-defined comparison algorithm, the `Set.Make` functor takes a module that specifies both the element type `t` and the `compare` function. Passing the comparison function as a higher-order parameter, as done in `Array.sort`, for example, would add a lot of boilerplate code. Providing set operations as a functor allows specifying the comparison function only once.

Here is an example of how to use `Set.Make`:

Expand Down

0 comments on commit 762cdf3

Please sign in to comment.