Skip to content

Commit

Permalink
@functor Returns (#71)
Browse files Browse the repository at this point in the history
* functor Returns

* Update src/base.jl

Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>

* Update test/base.jl

---------

Co-authored-by: Brian Chen <ToucheSir@users.noreply.github.com>
  • Loading branch information
mcabbott and ToucheSir authored Sep 2, 2023
1 parent fa601bb commit 19788ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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.4.5"
version = "0.4.6"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
4 changes: 4 additions & 0 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
@functor Base.Fix2
@functor Base.Broadcast.BroadcastFunction

@static if VERSION >= v"1.7"
@functor Base.Returns
end

###
### Array wrappers
###
Expand Down
6 changes: 6 additions & 0 deletions test/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ end
@test fmap(x -> x + 10, bf) == Base.Broadcast.BroadcastFunction(Bar(13.3))
end

VERSION >= v"1.7" && @testset "Returns" begin
ret = Returns([0, pi, 2pi])
@test Functors.functor(ret)[1] == (value = [0, pi, 2pi],)
@test Functors.functor(ret)[2]((value = 1:3,)) === Returns(1:3)
end

@testset "LinearAlgebra containers" begin
@test fmapstructure(identity, [1,2,3]') == (parent = [1, 2, 3],)
@test fmapstructure(identity, transpose([1,2,3])) == (parent = [1, 2, 3],)
Expand Down

5 comments on commit 19788ea

@oschulz
Copy link
Contributor

@oschulz oschulz commented on 19788ea Feb 8, 2024

Choose a reason for hiding this comment

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

@ToucheSir could you call Registrator on this commit, retroactively?

@ToucheSir
Copy link
Member

Choose a reason for hiding this comment

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

Strange, I thought I had.

@ToucheSir
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/100444

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.4.6 -m "<description of version>" 19788eaf785ff4b29e855429ebdfaee05c149321
git push origin v0.4.6

@oschulz
Copy link
Contributor

@oschulz oschulz commented on 19788ea Feb 8, 2024

Choose a reason for hiding this comment

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

Thanks @ToucheSir !

Please sign in to comment.