flux-rs / flux

Refinement Types for Rust
MIT License
581 stars 17 forks source link

Support all Binary Operations #644

Closed ranjitjhala closed 4 weeks ago

ranjitjhala commented 4 weeks ago

Instead of listing all the signatures we could have "templates" and then match a specific set of input types to a template. For example:

BitAnd :: fn<T>(a: T, b: T) -> T{v: true}
          where T: Integer
BitAnd :: fn(a: bool, b: bool) -> bool[a && b]
Shl  ::  fn<T, S>(a: T, b: S) -> T{v: true}
         where T: Integer, S: Integer

The first one would match if both input types are the same but must be an integer (signed or unsigned). The second one would only match if both inputs are bools and so on.

Maybe I'll implement it at some point.

_Originally posted by @nilehmann in https://github.com/flux-rs/flux/pull/643#discussion_r1657789111_