μ-types #109

Closed
phadej opened this Issue May 4, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@phadej
Member

phadej commented May 4, 2015

Add μ-types to the DSL.

Example:

function toTree(struct) {
  // struct is either
  switch (struct.index) {
    case 0: return new Tree(struct[0], struct[1], struct[2]);
    case 1: return null;
  }
}

function fromTree(tree) {
  if (tree !== null) {
    return jsc.mkSum(0, 2, [tree.element, tree.left, tree.right]);
  } else {
    return jsc.mkSum(1, 2, null);
  }
}

function treeArb(elArb) {
  return jsc.compile("μ t. (el t t) | null", { el: elArb }).smap(toTree, fromTree);
}

@phadej phadej added the enhancement label May 4, 2015

@joneshf

This comment has been minimized.

Show comment
Hide comment
@joneshf

joneshf May 5, 2015

Contributor

Nice!

Contributor

joneshf commented May 5, 2015

Nice!

@phadej phadej added this to the 0.7.0 milestone Jul 27, 2015

@phadej

This comment has been minimized.

Show comment
Hide comment
@phadej

phadej Jul 28, 2015

Member

Started working on this #126

Member

phadej commented Jul 28, 2015

Started working on this #126

@phadej phadej closed this Aug 22, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment