From 35008ead15accc45a1fc54f230e93a3dad2d9681 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Wed, 13 Mar 2024 08:52:00 -0400 Subject: [PATCH 1/3] functor Base.Splat --- src/base.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/base.jl b/src/base.jl index 6bcd8b0..ee14b33 100644 --- a/src/base.jl +++ b/src/base.jl @@ -9,6 +9,7 @@ @functor Base.Fix1 @functor Base.Fix2 @functor Base.Broadcast.BroadcastFunction +@functor Base.Splat @static if VERSION >= v"1.7" @functor Base.Returns From 7b2582e3c9a43d1b116f2a8550977c48b2e2a630 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Wed, 13 Mar 2024 08:56:30 -0400 Subject: [PATCH 2/3] add a test --- test/base.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/base.jl b/test/base.jl index 5ac5bea..ef7e99d 100644 --- a/test/base.jl +++ b/test/base.jl @@ -56,6 +56,12 @@ VERSION >= v"1.7" && @testset "Returns" begin @test Functors.functor(ret)[2]((value = 1:3,)) === Returns(1:3) end +@testset "Splat" begin + ret = Base.splat(Returns([0, pi, 2pi])) + @test Functors.functor(ret)[1].f.value == [0, pi, 2pi] + @test Functors.functor(ret)[2]((f = sin,)) === Base.splat(sin) +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],) From d834aca27d80ce24e4e329ef59cb336c802367a0 Mon Sep 17 00:00:00 2001 From: Michael Abbott <32575566+mcabbott@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:19:57 -0400 Subject: [PATCH 3/3] Apply suggestions from code review --- src/base.jl | 5 ++++- test/base.jl | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/base.jl b/src/base.jl index ee14b33..913aaa7 100644 --- a/src/base.jl +++ b/src/base.jl @@ -9,7 +9,10 @@ @functor Base.Fix1 @functor Base.Fix2 @functor Base.Broadcast.BroadcastFunction -@functor Base.Splat + +@static if VERSION >= v"1.9" + @functor Base.Splat +end @static if VERSION >= v"1.7" @functor Base.Returns diff --git a/test/base.jl b/test/base.jl index ef7e99d..e06d415 100644 --- a/test/base.jl +++ b/test/base.jl @@ -56,7 +56,7 @@ VERSION >= v"1.7" && @testset "Returns" begin @test Functors.functor(ret)[2]((value = 1:3,)) === Returns(1:3) end -@testset "Splat" begin +VERSION >= v"1.9" && @testset "Splat" begin ret = Base.splat(Returns([0, pi, 2pi])) @test Functors.functor(ret)[1].f.value == [0, pi, 2pi] @test Functors.functor(ret)[2]((f = sin,)) === Base.splat(sin)