-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typeof(::ComposedOptic) #16
Comments
Just found this: If I'm reading this right, it seems that in 1.6 |
Sounds really exciting I need to check this out.
I think you can just dispatch on Accessors.ComposedOptic. Accessors.jl does this also internally. On 1.5 it is an alias for the scary looking |
It's mostly here, specifically in function sourceSample()
function(m::Model)
_m = canonical(m)
proc(_m, st::Assign) = :($(st.x) = $(st.rhs))
proc(_m, st::Sample) = :($(st.x) = value(sample(_rng, $(st.rhs))))
proc(_m, st::Return) = :(_value = $(st.rhs))
proc(_m, st::LineNumber) = nothing
vals = map(x -> Expr(:(=), x,x),parameters(_m))
wrap(kernel) = @q begin
_rng -> begin
_value = nothing
$kernel
_trace = $(Expr(:tuple, vals...))
return (value = _value, trace = _trace)
end
end
buildSource(_m, proc, wrap) |> flatten
end
end The
Great! I'll try this, thanks :) |
Confirmed!! julia> using Accessors
julia> outeroptic(::Accessors.ComposedOptic{A,B}) where {A,B} = A
outeroptic (generic function with 1 method)
julia> o = @optic _.a.b
(@optic _.b) ∘ (@optic _.a)
julia> outeroptic(o)
Accessors.PropertyLens{:b} |
Just opened cscherrer/Soss.jl#227 I think this is resolved on the Accessors side, thanks @jw3126 |
Oh, last post here wasn't clear. I mean I'll close the issue, since it's currently more an issue on the Soss side. @jw3126 if you're interested I'd welcome any feedback there :) |
hi, I'm starting to think Accessors can be a big role in Soss, not just as a library, but also in the generated code I use for sampling. The idea would be to have a collection of optics for each model, and compose these to descend into submodels.
To make this work, I need to have type-level representation of
PropertyLens
andComposedOptic
. A quick test givesI had thought maybe I can get
::ComposedOptic
more directly, butWorking in terms of
Base.var"#62#63"
for generated code seems very error-prone. Is there a better way to do this?The text was updated successfully, but these errors were encountered: