@@ -10,20 +10,20 @@ date: 2021-05-27T21:07:30-00:00
1010# Functors
1111
1212Functors 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,
1414you may never have to define a functor yourself, but you will surely encounter
1515them in the standard library. They are the only way of using the Set and Map
1616modules, 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
2424in 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
2727of those functions, it will result in a compilation error. If we were not using
2828this functor but the standard array type, the compiler would not be able to
2929detect 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
3838function 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
9797For 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
177177end
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