Skip to content

Commit 09bf849

Browse files
authored
all Types are leaf (#95)
1 parent 8bb69eb commit 09bf849

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Functors"
22
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
33
authors = ["Mike J Innes <[email protected]>"]
4-
version = "0.5.0"
4+
version = "0.5.1"
55

66
[deps]
77
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

docs/src/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Using [`@leaf`](@ref) instead of [`@functor`](@ref) will prevent the fields of a
6262
By default all composite types in are functors and can be traversed, unless marked with [`@leaf`](@ref).
6363

6464
The following types instead are explicitly marked as leaves in Functors.jl:
65+
- `Type`
6566
- `Number`.
6667
- `AbstractArray{<:Number}`, except for the wrappers `Transpose`, `Adjoint`, and `PermutedDimsArray`.
6768
- `AbstractRNG`.

src/base.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
### Opt-Out
33
###
44

5+
@leaf Type
56
@leaf Number
67
@leaf AbstractArray{<:Number}
78
@leaf AbstractString

test/base.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,11 @@ end
211211
@test od2 isa OrderedDict
212212
@test od2[1] == 2
213213
@test od2[2] == 4
214-
end
214+
end
215+
216+
@testset "Types are leaves" begin
217+
@test Functors.isleaf(Int)
218+
@test Functors.isleaf(Array)
219+
@test fmap(identity, (1,Int,Ref,Array,5)) == (1,Int,Ref,Array,5)
220+
end
221+

0 commit comments

Comments
 (0)