-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Type Aliases #1163
base: canary
Are you sure you want to change the base?
Implement Type Aliases #1163
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Generated with ❤️ by ellipsis.dev |
@imalsogreg Fixed! |
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Adds `RunFoo2` function across clients, new types, refines recursive type handling, and updates unreachable code with context. > > - **New Functionality**: > - Adds `RunFoo2` function to Python (`async_client.py`, `sync_client.py`), Ruby (`client.rb`), and TypeScript (`async_client.ts`, `sync_client.ts`) clients. > - Introduces `Foo2` and `Foo3` types in `types.py`, `types.rb`, and `types.ts`. > - **Code Improvements**: > - Replaces `unreachable!()` with `unreachable!("context")` in `expr.rs`, `coerce_array.rs`, `coerce_optional.rs`, and `coerce_union.rs`. > - Refactors recursive type handling in `types.rs`. > - **Testing**: > - Adds `test_constrained_type_alias` in `test_runtime.rs`. > - Adds `test_type_alias_with_assert` in `test_file_manager.rs`. > - Adds `test_alias_bug` in `test_functions.py`. > - **Miscellaneous**: > - Adds `antonio.baml` test file for integration tests. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 10f4999. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: Greg Hale <[email protected]>
This is just a thought for later, definitely not something i would suggest implementing now: Some time in the future, I think Pros/Cons to this proposal:
Again - this is just some thought about the future, definitely not a change we should make now. But I'm curious @antoniosarosi what you think about it. |
Thought about removing |
Allow structural recursion (like TS): ```baml type RecursiveMap = map<string, RecursiveMap> type A = A[] ``` Follow up on #1163 <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Enable structural recursion in type aliases by updating cycle validation logic, adding tests, and supporting recursive type aliases in Python, Ruby, and TypeScript clients. > > - **Behavior**: > - Allow structural recursion for type alias cycles involving maps and lists in `cycle.rs`. > - Update `validate()` in `cycle.rs` to handle structural recursion and report cycles. > - Modify `ParserDatabase::finalize_dependencies()` in `lib.rs` to resolve type aliases and handle cycles. > - **Functions**: > - Add `insert_required_alias_deps()` in `cycle.rs` to handle alias dependencies. > - Rename `insert_required_deps()` to `insert_required_class_deps()` in `cycle.rs`. > - **Models**: > - Add `structural_recursive_alias_cycles` to `Types` in `mod.rs`. > - **Tests**: > - Update `recursive_type_aliases.baml` to reflect new cycle validation behavior. > - Add tests in `lib.rs` to verify structural recursion handling. > - **Language Support**: > - Update Python, Ruby, and TypeScript clients to handle recursive type aliases. > - **Misc**: > - Add `is_subtype()` to `IRHelper` in `mod.rs` to support subtyping checks. > - Add `coerce_alias()` in `coerce_alias.rs` to handle alias coercion. > - Add integration tests for recursive alias cycles in `integ-tests/typescript/tests/integ-tests.test.ts`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for fc25050. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
Implementation of TS-like type aliases (structural recursion allowed through maps and lists).
Basic aliases:
Recursive aliases:
See also #1207