Skip to content

Commit 3ca2ef4

Browse files
christineroseCuihtlauac ALVARADO
authored andcommitted
Line editing for Functors (#1127)
1 parent c26e68e commit 3ca2ef4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

data/tutorials/lg_06_functors.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ date: 2021-05-27T21:07:30-00:00
1010
# Functors
1111

1212
Functors are probably one of the most complex features of OCaml, but you don't
13-
have to use them extensively to be a successful OCaml programmer. Actually,
13+
have to use them extensively to be a successful OCaml programmer. Actually,
1414
you may never have to define a functor yourself, but you will surely encounter
1515
them in the standard library. They are the only way of using the Set and Map
1616
modules, but using them is not so difficult.
1717

1818
## What Are Functors and Why Do We Need Them?
1919

20-
A functor is a module that is parametrized by another module, just like a
21-
function is a value which is parametrized by other values, the arguments.
20+
A functor is a module that is parametrised by another module, just like a
21+
function is a value which is parametrised by other values, the arguments.
2222

23-
It allows one to parametrize a type by a value, which is not possible directly
23+
It allows one to parametrise a type by a value, which is not possible directly
2424
in OCaml without functors. For example, we can define a functor that takes an
25-
int n and returns a collection of array operations that work exclusively on
26-
arrays of length n. If by mistake the programmer passes a regular array to one
25+
`int n` and returns a collection of array operations that work exclusively on
26+
arrays of length `n`. If by mistake the programmer passes a regular array to one
2727
of those functions, it will result in a compilation error. If we were not using
2828
this functor but the standard array type, the compiler would not be able to
2929
detect the error, and we would get a runtime error at some undetermined date in
@@ -37,7 +37,7 @@ things: the type of elements, given as `t` and the comparison function given as
3737
`compare`. The point of the functor is to ensure that the same comparison
3838
function will always be used, even if the programmer makes a mistake.
3939

40-
For example, if we want to use sets of ints, we would do this:
40+
For example, if we want to use sets of `ints`, we would do this:
4141

4242
```ocaml
4343
# module Int_set =
@@ -96,8 +96,8 @@ module Int_set :
9696

9797
For sets of strings, it is even easier because the standard library provides a
9898
`String` module with a type `t` and a function `compare`. If you were following
99-
carefully, by now you must have guessed how to create a module for the
100-
manipulation of sets of strings:
99+
carefully, by now you must have guessed how to create a module to
100+
manipulate string sets:
101101

102102
```ocaml
103103
# module String_set = Set.Make (String);;
@@ -177,7 +177,7 @@ struct
177177
end
178178
```
179179

180-
or by specifying this in the .mli file:
180+
or by specifying this in the `.mli` file:
181181

182182
<!-- $MDX skip -->
183183
```ocaml

0 commit comments

Comments
 (0)