Skip to content

Instantly share code, notes, and snippets.

@TonyLo1
Created September 22, 2016 15:15
Show Gist options
  • Save TonyLo1/e8d43fea19d79e158d3876e66f70a336 to your computer and use it in GitHub Desktop.
Save TonyLo1/e8d43fea19d79e158d3876e66f70a336 to your computer and use it in GitHub Desktop.
primitive Inh
primitive Sim
primitive Imp
primitive Equ
primitive And
primitive Or
type Rel is (Inh | Sim | Imp | Equ | And | Or)
type Term is (String | Relation)
class Relation
var term : (Rel, Array[Term])
new create(rel : Rel, term' : Array[Term]) =>
term = (rel, term')
actor Main
let t1 : Term = "cat"
let t2 : Term = "animal"
let t3 : Term = Relation(Inh, [t1, t2]) // compiles
let t4 : Term = Relation(Inh, ["cat", t2]) // compiles
let t5 : Term = Relation(Inh, [t1, "animal"]) // compiles
let t6 : Term = Relation(Inh, ["cat", "animal"]) // Fails to compile
new create(env: Env) =>
env.out.print("Done")
@TonyLo1
Copy link
Author

TonyLo1 commented Sep 22, 2016

The above code fails at line 23.

main.pony:23:33: argument not a subtype of parameter let t6 : Term = Relation(Inh, ["cat", "animal"]) // Fails to compile

My guess is that the array is being cast to Array[String] and failing to match. Is there a way to force the parameter type?

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