kyle
AEAsh Elixir
•Created by kyle on 5/25/2023 in #support
Spark.Dsl.Entity is option explicit or inferred?
pr sent, lmk if that looks right
29 replies
AEAsh Elixir
•Created by kyle on 5/25/2023 in #support
Spark.Dsl.Entity is option explicit or inferred?
interesting...I gave up poking around L1619 before, I'll take a look at this, thanks
29 replies
AEAsh Elixir
•Created by kyle on 5/25/2023 in #support
Spark.Dsl.Entity is option explicit or inferred?
no promises but sure
29 replies
AEAsh Elixir
•Created by kyle on 5/25/2023 in #support
Spark.Dsl.Entity is option explicit or inferred?
I'm generating some ash resources from a json definition, was hoping I could just monkeypatch the entities with the transformer but I don't want to overwrite any explicitly set options so...
29 replies
AEAsh Elixir
•Created by kyle on 5/25/2023 in #support
Spark.Dsl.Entity is option explicit or inferred?
also, not seeing how to mark as solved in the discord app, sorry for leaving open atm
29 replies
AEAsh Elixir
•Created by kyle on 5/25/2023 in #support
Spark.Dsl.Entity is option explicit or inferred?
😔 maybe someday? seems like it would be useful for overriding default behaviour. hacked this together for now, definitely not complete code (need to check that the path is valid and not accidentally a deep match) but works for me, for now, and sharing is caring so:
def is_set?(dsl_state, path, key) do
{:ok, ast} = dsl_state.persist.file |> File.read!() |> Code.string_toquoted()
pre = fn
{head, meta, [^key | args]}, {[head], } -> {[], true}
{form, meta, [^key | args]}, {[], } -> {[], true}
{head, meta, args}, {[head | left], right} -> {{head, meta, args}, {left, [head | right]}}
ast, acc -> {ast, acc}
end
post = fn
{head, meta, args}, {left, [head | right]} -> {{head, meta, args}, {[head | left], right}}
ast, acc -> {ast, acc}
end
{, found?} = Macro.traverse(ast, {path, []}, pre, post)
found? == true
end
29 replies