Skip to content

Commit

Permalink
Merge branch 'master' into gadts
Browse files Browse the repository at this point in the history
  • Loading branch information
yminsky committed Jan 24, 2022
2 parents b7f09c6 + 7038567 commit 9944248
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions book/gadts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,11 @@ you add a step to a pipeline by providing a function to prepend on to
an existing pipeline, and `empty` gives you an empty pipeline, which
can be used to seed the pipeline.

We can use a functor to show how we could use this API for building a
pipeline like our earlier example using `|>`.
The following shows how we could use this API for building a pipeline
like our earlier example using `|>`. Here, we're using a *functor*,
which we'll see in more detail in
[Functors](functors.html#functors){data-type=xref}, as a way to write
code using a given API before we've implemented it.

```ocaml env=abstracting
# module Example_pipeline (Pipeline : Pipeline) = struct
Expand Down Expand Up @@ -829,12 +832,11 @@ extra services we discussed. All we're really doing is step-by-step
building up the same kind of function that we could have gotten using
the `|>` operator.

If we wanted to add the kinds of services we discussed above, we would
do so by enhancing the pipeline type, e.g., providing it with extra
runtime structures to track profiles, or handle exceptions. But this
approach is awkward, since it requires us to pre-commit to whatever
services we're going to support, and to embed all of them in our
pipeline representation.
We could get a more poweful pipeline by simply enhancing the pipeline
type, providing it with extra runtime structures to track profiles, or
handle exceptions. But this approach is awkward, since it requires us
to pre-commit to whatever services we're going to support, and to
embed all of them in our pipeline representation.

GADTs provide a simpler approach. Instead of concretely building a
machine for executing a pipeline, we can use GADTs to abstractly
Expand Down
2 changes: 1 addition & 1 deletion book/toc.scm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
variants
error-handling
imperative-programming
gadts
functors
first-class-modules
gadts
objects
classes))))

Expand Down

0 comments on commit 9944248

Please sign in to comment.