Skip to content

Commit

Permalink
all Types are leaf (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott authored Nov 7, 2024
1 parent 8bb69eb commit 09bf849
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Functors"
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
authors = ["Mike J Innes <mike.j.innes@gmail.com>"]
version = "0.5.0"
version = "0.5.1"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Using [`@leaf`](@ref) instead of [`@functor`](@ref) will prevent the fields of a
By default all composite types in are functors and can be traversed, unless marked with [`@leaf`](@ref).

The following types instead are explicitly marked as leaves in Functors.jl:
- `Type`
- `Number`.
- `AbstractArray{<:Number}`, except for the wrappers `Transpose`, `Adjoint`, and `PermutedDimsArray`.
- `AbstractRNG`.
Expand Down
1 change: 1 addition & 0 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### Opt-Out
###

@leaf Type
@leaf Number
@leaf AbstractArray{<:Number}
@leaf AbstractString
Expand Down
9 changes: 8 additions & 1 deletion test/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,11 @@ end
@test od2 isa OrderedDict
@test od2[1] == 2
@test od2[2] == 4
end
end

@testset "Types are leaves" begin
@test Functors.isleaf(Int)
@test Functors.isleaf(Array)
@test fmap(identity, (1,Int,Ref,Array,5)) == (1,Int,Ref,Array,5)
end

2 comments on commit 09bf849

@CarloLucibello
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/118870

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.1 -m "<description of version>" 09bf849dee20364ad42a94c67b5fa4d93d8b41f2
git push origin v0.5.1

Please sign in to comment.