Feature/typed action input inference - #2915
Draft
Alt-iOS wants to merge 15 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor checklist
Summary
This draft explores compile-time type checking for Ash action inputs inside changes, validations, and preparations using Elixir’s set-theoretic type system.
Ash already knows each action’s arguments, accepted attributes, types, and nilability. This change exposes that information to the compiler through temporary type-witness modules.
How it works
%Ash.Changeset{}or%Ash.Query{}witnesses for each action.--forcerecompiles all witnesses.This depends on the accompanying Spark change that introduces the generic callback-lifting hook.
Currently supported
manage_relationship.change/3,atomic/3, andbatch_change/3.Example diagnostics
Unknown changeset field:
Unknown action argument:
Incorrect value type:
Ash declares
quantityasinteger(), while<>/2requires a binary, so Elixir reports the incompatible types during compilation.Current limitations
Ash.Typeimplementations that cannot be reduced to a known primitive or struct remain dynamic.Some diagnostics produced through local inline callbacks are technically correct but difficult to read because Elixir infers the callback requirement backward and reports the conflict at the call boundary. Improving those messages is possible follow-up work.
Verification
A full demo of all available diagnostics is at https://github.com/Alt-iOS/ash_type_inference_demo