FluxML / FluxML/Functors.jl

`@functor` for parametric constructors

Open
#40 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
123
Forks
18
Avg merge
47m
Merged PRs (30d)
1

Description

Suppose I have a type
```
using Functors
struct Foo{T1,T2}
x::T2
Foo{T1}(x::T2) where {T1,T2} = new{T1,T2}(x)
end
```
Then using
```
@functor Foo
```
will not manage to capture the `T1` type:
```
x = Foo{Real}(2.0)
y, re = Functors.functor(x)
re(y)
ERROR: MethodError: no method matching Foo(::Float64)
Stacktrace:
[1] (::var"#5#6")(y::NamedTuple{(:x,), Tuple{Float64}})
@ Main ~/.julia/packages/Functors/qBIlC/src/functor.jl:23
[2] top-level scope
@ REPL[14]:1
```
using
```
@functor Foo{T} where {T}
```
is not helping more

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the parametric Foo example with @functor and inspect functor.jl around line 23, where the reconstruction call fails. Compare the behavior of @functor Foo and @functor Foo{T} where {T}; done means Functors.functor(x) retains the T1 parameter so re(y) succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.