https://github.com/lynn/yuki
in which I play around with bidirectional typechecking
https://github.com/lynn/yuki
Last synced: 2 months ago
JSON representation
in which I play around with bidirectional typechecking
- Host: GitHub
- URL: https://github.com/lynn/yuki
- Owner: lynn
- License: mit
- Created: 2020-11-23T01:56:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-26T19:47:31.000Z (over 2 years ago)
- Last Synced: 2025-03-17T10:12:25.654Z (2 months ago)
- Language: Python
- Size: 23.4 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yuki ❄️
in which I play around with bidirectional typechecking`pip3 install mypy parsy`, then `mypy yuki.py` and `python3 yuki.py`
it's very WIP, but one day this kind of thing will typecheck:
```ml
(* this is the very cool and good type of integer multiplication in this type system *)
(* & is taking the intersection of function types: *)
mul : (pos ->pos ->pos ) & (pos ->zero->zero) & (pos ->neg ->neg )
& (zero->pos ->zero) & (zero->zero->zero) & (zero->neg ->zero)
& (neg ->pos ->neg ) & (neg ->zero->zero) & (neg ->neg ->pos )
mul = __builtin_mul(* and | is taking the union of value types: *)
square : (zero|pos|neg) -> (zero|pos)
square = fn x => mul x x
```(so, the integer type is a union `zero|pos|neg`, and we infer from the type of `mul` that a `square` is indeed never `neg`ative.)