alpaca-lang / alpaca

Functional programming inspired by ML for the Erlang VM
Other
1.44k stars 47 forks source link

Basic type alias support #257

Closed j14159 closed 6 years ago

j14159 commented 6 years ago

Fixes #234, at least mostly. With these changes:

type r = {x: int, y: string}

Will be interpreted as a type alias (#alpaca_type_alias{}). This makes some reuse easier, e.g. binding in test_files/future_ast.alp. Previously these untagged single-member type declarations resulted in a full ADT which made instantiation both error prone and unnecessarily complex.

Note that this still produces an #adt{}:

type r 'x = {x: 'x, y: string}

I'm not sure how I'd like to change this yet, if at all. There's a bit of a hack in this PR that gets around the ADT nature of this sort of type.