Skip to content

Instantly share code, notes, and snippets.

@deech
Created November 1, 2016 01:34
Show Gist options
  • Save deech/64a8942eb7e2fc0364e8ee4c80f2780c to your computer and use it in GitHub Desktop.
Save deech/64a8942eb7e2fc0364e8ee4c80f2780c to your computer and use it in GitHub Desktop.
Shen Union type
(datatype whisky
if (element? X [bourbon scotch])
________________________________
X : whisky;)
(datatype beer
if (element? X [lager stout])
______________________________
X : beer;)
(datatype union
X : A;
________________________
X : (mode (union A B) -);
X : B;
_________________________
X : (mode (union A B) -);)
(define union-test
{(union whisky beer) --> (union whisky beer) --> (list (union whisky beer))}
W B -> [W B])
\*
> (union-test lager scotch)
[lager scotch] : (list (union whisky beer))
*\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment