Created
September 22, 2016 15:15
-
-
Save TonyLo1/e8d43fea19d79e158d3876e66f70a336 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?