Skip to content
/ yuki Public

in which I play around with bidirectional typechecking

License

Notifications You must be signed in to change notification settings

lynn/yuki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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:

(* 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 negative.)

About

in which I play around with bidirectional typechecking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages