Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NekoML: Improvement on Type Inference #185

Open
audinue opened this issue Sep 6, 2018 · 0 comments
Open

NekoML: Improvement on Type Inference #185

audinue opened this issue Sep 6, 2018 · 0 comments

Comments

@audinue
Copy link

audinue commented Sep 6, 2018

Not really a bug, just improvement 😄

type node {
  Number  : (float)
  Add     : (node, node)
  Multiply: (node, node)
}

function rec eval(node) { // Awesome.nml(11): Cannot unify int and float
  match node {
    | Number(value) -> value // this is float
    | Add(left, right) -> eval(left) + eval(right)
    | Multiply(left, right) -> eval(left) * eval(right)
  }
}

var node = Add(Number(1.0), Multiply(Number(2.0), Number(3.0)));

print(eval(node));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant