Skip to content

Add support for variants #2

@gabejohnson

Description

@gabejohnson

In place of traditional sum and product types, the plan is to only support polymorphic records and variants. The records are already in place, so that just leaves the variants.

In order to support variant elimination, we need a way to handle the cases. This could be done w/ if or switch statements, but I'd like to use babel/babel#7633 if it's not too much work.

Variant types would be declared as follow (via the Flow type AST):

type Either<l,r> = {Left: l} | {Right: r};

let
either: <l,r,a>(l => a) => (r => a) => Either<l,r> => a;
either = f => g => e => match(e) {
  ({Left: l}) => f(l),
  ({Right: r}) => g(r)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions