Skip to content

Instantly share code, notes, and snippets.

@vito
Created December 7, 2010 23:05
Show Gist options
  • Save vito/732607 to your computer and use it in GitHub Desktop.
Save vito/732607 to your computer and use it in GitHub Desktop.
Object -- Unary 1; the root trait, very first one created; 1 is its "tag"
Foo = Object clone -- Union (Unary 2) (Unary 1) (@clone might become @derive or something)
Bar = Foo clone -- Union (Unary 3) (Union (Unary 2) (Unary 1))
Fizz = Foo clone -- Union (Unary 4) (Union (Unary 2) (Unary 1))
-- defines on trait:
-- Intersection (Unary 2) (Unary 3)
-- note that the unions are gone; it only intersects on the "heads"
(f: Foo) x: (b: Bar) := 1
-- searches for trait:
-- Intersection (Union (Unary 2) (Unary 1)) (Union (Unary 3) (Union (Unary 2) (Unary 1)))
-- ie, any trait in unions can match
Foo x: Bar
=> 1
-- also finds @x: because Unary 2 is in Fizz's union
-- Bar x: Bar would work too
Fizz x: Bar
=> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment