Skip to content

Commit 1fdf055

Browse files
authored
doc fixup (#44)
1 parent 0e5356f commit 1fdf055

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

docs/src/assets/flux.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ article pre {
100100
max-width: none;
101101
padding: 1em;
102102
border-radius: 10px 0px 0px 10px;
103-
margin-left: -1em;
104-
margin-right: -2em;
105103
}
106104

107105
.hljs-comment {

docs/src/assets/logo.png

83.6 KB
Loading

docs/src/index.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@
22

33
Functors.jl provides a set of tools to represent [functors](https://en.wikipedia.org/wiki/Functor_(functional_programming)). Functors are a powerful means to apply functions to generic objects without changing their structure.
44

5-
Functors can be used in a variety of ways. One is to traverse a complicated or nested structure as a tree and apply a function `f` to every field it encounters along the way.
5+
The most straightforward use is to traverse a complicated nested structure as a tree, and apply a function `f` to every field it encounters along the way.
66

77
For large models it can be cumbersome or inefficient to work with parameters as one big, flat vector, and structs help manage complexity; but it may be desirable to easily operate over all parameters at once, e.g. for changing precision or applying an optimiser update step.
88

9-
## Appropriate Use
10-
11-
!!! warning "Not everything should be a functor!"
12-
Due to its generic nature it is very attractive to mark several structures as [`@functor`](@ref) when it may not be quite safe to do so.
13-
14-
Typically, since any function `f` is applied to the leaves of the tree, but it is possible for some functions to require dispatching on the specific type of the fields causing some methods to be missed entirely.
15-
16-
Examples of this include element types of arrays which typically have their own mathematical operations defined. Adding a [`@functor`](@ref) to such a type would end up missing methods such as `+(::MyElementType, ::MyElementType)`. Think `RGB` from Colors.jl.
17-
189
## Basic Usage and Implementation
1910

2011
When one marks a structure as [`@functor`](@ref) it means that Functors.jl is allowed to look into the fields of the instances of the struct and modify them. This is achieved through [`Functors.fmap`](@ref).
@@ -61,3 +52,11 @@ Baz(1.0, 2)
6152

6253
Any field not in the list will be passed through as-is during reconstruction. This is done by invoking the default constructor, so structs that define custom inner constructors are expected to provide one that acts like the default.
6354

55+
## Appropriate Use
56+
57+
!!! warning "Not everything should be a functor!"
58+
Due to its generic nature it is very attractive to mark several structures as [`@functor`](@ref) when it may not be quite safe to do so.
59+
60+
Typically, since any function `f` is applied to the leaves of the tree, but it is possible for some functions to require dispatching on the specific type of the fields causing some methods to be missed entirely.
61+
62+
Examples of this include element types of arrays which typically have their own mathematical operations defined. Adding a [`@functor`](@ref) to such a type would end up missing methods such as `+(::MyElementType, ::MyElementType)`. Think `RGB` from Colors.jl.

0 commit comments

Comments
 (0)