checkpoint failing test after fixing tests checkpoint checkpoint checkpoint re-work asd checkpoint checkpoint checkpoint mix proj checkpoint mix first parser impl checkpoint fix tests re-org parser checkpoint strings fix multiline strings tuples checkpoint maps checkpoint checkpoint checkpoint checkpoint fix weird eof expression parse error checkpoint before typing checkpoint checpoint checkpoint checkpoint checkpoint ids in primitive types checkpoint checkpoint fix tests initial annotation checkpoint checkpoint checkpoint union subtyping conventions refactor - split typer typing tuples checkpoint test refactor checkpoint test refactor parsing atoms checkpoint atoms wip lists checkpoint typing lists checkopint checkpoint wip fixing correct list typing map discussion checkpoint map basic typing fix tests checkpoint checkpoint checkpoint checkpoint fix condition typing fix literal keys in map types checkpoint union types checkpoint union type checkpoint row types discussion & bidirectional typecheck checkpoint basic lambdas checkpoint lambdas typing application wip function application checkpoint checkpoint checkpoint cduce checkpoint checkpoint checkpoint checkpoint checkpoint checkpoint checkpoint
4.4 KiB
4.4 KiB
-
Implement Parsing for
(union <type1> <type2> ...)Type Specifiers:- Modify
Til.Typer.ExpressionTyper.resolve_type_specifier_nodeto recognize and parse S-expressions like(union integer string). - This will involve recursively resolving the inner type specifiers and constructing a raw union type definition. The existing interning and subtyping logic for unions can then be leveraged.
- Add tests for type checking expressions annotated with these explicit union types, e.g.,
(the (union integer string) some-expression).
- Modify
-
Implement Parsing for Basic Function Type Specifiers:
- Modify
Til.Typer.ExpressionTyper.resolve_type_specifier_nodeto parse function type specifiers, e.g.,(function (Arg1Type Arg2Type ...) ReturnType). - Add interning support for function types in
Til.Typer.Interner. - Implement basic subtyping rules for function types in
Til.Typer.SubtypeChecker(initially, arity checking; then contravariant arguments, covariant return).
- Modify
-
Implement Basic Function Definition (e.g.,
deforlambda):- Define syntax (e.g.,
(def my-fn (param1 param2) body-expr)). - Add parser support for this syntax.
- Typer:
- For this initial step, infer a basic function type (e.g., based on arity, with
anyfor parameter and return types if not annotated). - Add the function name and its inferred type to the environment.
- For this initial step, infer a basic function type (e.g., based on arity, with
- Define syntax (e.g.,
-
Implement Basic Function Calls:
- Extend
Til.Typer.ExpressionTyper.infer_s_expression_typefor function calls:- When the operator of an S-expression is a symbol, look up its type in the environment.
- If it's a function type (from step 4), perform an arity check against the provided arguments.
- The inferred type of the call would be the function's (currently basic) return type.
- Extend
-
Enhance Function Definitions with Type Annotations:
- Extend the function definition syntax to support type annotations for parameters and return types (e.g.,
(def my-fn ((p1 P1Type) (p2 P2Type)) :: ReturnType body-expr)). - Update the parser for this extended syntax.
- Typer:
- Use these annotations to construct a more precise function type.
- When typing the function body, use the annotated parameter types in the local environment.
- Verify that the inferred type of the function body is a subtype of the annotated return type.
- Update function call typing (from step 5) to use these precise function types for argument type checking and to determine the call's return type.
- Extend the function definition syntax to support type annotations for parameters and return types (e.g.,
-
Implement Type Inference for Core Map Operation:
(map-get map key):- Define the S-expression syntax
(map-get map-expr key-expr). - In
Til.Typer.ExpressionTyper, implement type inference rules formap-getbased on the logic outlined intodo.md. This includes:- Typing
map-exprandkey-expr. - Handling cases where
key-expr's type is a literal (allowing lookup inknown_elements). - Handling cases where
key-expr's type is a general type (usingindex_signatureand potentially unioning types fromknown_elements).
- Typing
- Define the S-expression syntax
-
Improve User-Facing Type Error Messages:
- For common errors like
type_annotation_mismatchor function call argument mismatches, enhance the error reporting. - Develop a utility to pretty-print type definitions (from their internal map representation or ID) for inclusion in error messages, making them more readable than raw type IDs or structures.
- Ensure source locations (file, line, column) are clearly associated with type errors.
- For common errors like
-
Implement Parsing for
(intersection <type1> <type2> ...)Type Specifiers:- Similar to union types, update
Til.Typer.ExpressionTyper.resolve_type_specifier_nodefor intersection type S-expressions. - Add interning and subtyping rules for intersection types in
Til.Typer.InternerandTil.Typer.SubtypeChecker.
- Similar to union types, update
-
Implement Simple Type Aliases (e.g.,
deftype):- Define syntax for non-generic type aliases (e.g.,
(deftype PositiveInteger (refinement integer ...))or(deftype UserMap (map atom any))). - Add parser support.
- Typer:
- Store these alias definitions.
- Modify
Til.Typer.ExpressionTyper.resolve_type_specifier_nodeto recognize and expand these aliases when they are used in type annotations.
- Define syntax for non-generic type aliases (e.g.,