Skip to content

Commit

Permalink
Complete conclusions for cycles chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Jun 30, 2023
1 parent 009c6db commit 44074ae
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions book/src/pages/cycles/conclusions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

This chapter has focused on function composition.
We've used `Angle => Point` functions to represent parametric curves,
and we have seen that we can build many useful abstractions around them by using function composition.
and we have seen that we can build many useful abstractions based on function composition.

Functions are not the only things that compose.
Every time we've used the `beside`, or `above` methods on `Image`, for example, we've been composing images.
This notion of composition is one of the key ideas in functional programming, and we'll continue to see it throughout the book.
Composition is one of the key ideas in functional programming, and we'll continue to see it throughout the book.
These methods are sometimes known as **combinators**.
This isn't a term we'll use much, but you may find it in other literature so it's useful to know what it means.

closure
The methods of composition, or combinators, all have a property known as **closure**.
This means that the input is the same sort of thing as the output.
When we combine two `Images` using `above` we get back an `Image`.
When we combine two functions using `andThen` we get back a function.

combinators
It isn't necessary for all the parameters of a method to have the same type for a method to be a combinator.
For example, `strokeColor` combiines an `Image` and a `Color` to produce an `Image`.
We still consider this a combinator because we're most interested in the `Image` type, which is both an input and an output of `strokeColor`.
So we could say that `strokeColor` composes an `Image` and a `Color` to produce an `Image`.

0 comments on commit 44074ae

Please sign in to comment.