Constraint types #15

Merged
HEL merged 26 commits from feat/constraint-type into main 2026-06-19 20:21:04 +00:00
Owner

This PR implements constraint types, both in the types ecosystem and as generated runtime assertions.
For the approach is quite naive in that:

  • predicate definition is restricted to a subset of Python that is manually parsed (with many redundant parts from PythonParser copied over to MidasParser, for example to resolve function calls)
  • subtyping only checks the base type, not the constraints
  • there is no constraint optimization when combining multiple predicates, nor when generating runtime assertions (e.g. to avoid creating identical functions)
  • the syntax and grammar for defining predicates is still a bit blurry, especially for parameters. Parameters are technically mixed (positional or keyword), but the underlying structures are the same as for functions, i.e. including positional- and keyword-only parameters, default values, etc.
This PR implements constraint types, both in the types ecosystem and as generated runtime assertions. For the approach is quite naive in that: - predicate definition is restricted to a subset of Python that is manually parsed (with many redundant parts from `PythonParser` copied over to `MidasParser`, for example to resolve function calls) - subtyping only checks the base type, not the constraints - there is no constraint optimization when combining multiple predicates, nor when generating runtime assertions (e.g. to avoid creating identical functions) - the syntax and grammar for defining predicates is still a bit blurry, especially for parameters. Parameters are technically mixed (positional or keyword), but the underlying structures are the same as for functions, i.e. including positional- and keyword-only parameters, default values, etc.
HEL self-assigned this 2026-06-19 20:20:31 +00:00
HEL added 26 commits 2026-06-19 20:20:41 +00:00
handle cases where a predicate is defined as an alias, i.e. without any parameters
temporarily change type errors in predicates to warnings until operations are fully type checked
HEL force-pushed feat/constraint-type from 776a3fb86c to 3205e7b961 2026-06-19 20:20:41 +00:00 Compare
HEL merged commit 6eea0c02e0 into main 2026-06-19 20:21:04 +00:00
HEL deleted branch feat/constraint-type 2026-06-19 20:21:04 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: HEL/midas#15