This project demonstrates experimental compile-time type checking for Ash action inputs. It intentionally contains invalid callback code, so its compiler warnings are the expected output.
git clone https://github.com/Alt-iOS/ash_type_inference_demo.git
cd ash_type_inference_demo
mix deps.get
mix compile --warnings-as-errorsThe final command should fail with type diagnostics. To print the same warnings without treating them as errors:
mix compile --forceThe project uses the feature/typed-action-input-inference branches of the Alt-iOS Ash and Spark
forks.
- Exact action-argument and accepted-attribute keys
- Primitive value types and nilability
- Constrained maps
- Embedded resources and arrays of embedded resources
- Inputs passed through
manage_relationship - Inline and dispatched changes
change/3,atomic/3, andbatch_change/3- Validations and preparations
- Literal callback options
- Friendly diagnostics for invalid fields on
%Ash.Changeset{}
Each module is in a separate file so dispatched, cross-module inference is visible.
The compiler builds type-witness modules in memory. Print their generated Elixir source with:
mix run --no-compile -e '
Ash.Resource.TypeInference.witness_entries([AshTypeInferenceDemo.Resource])
|> Enum.each(fn entry ->
IO.puts("\n# #{inspect(entry.key)}\n")
IO.puts(Macro.to_string(entry.definition))
end)
'