public static bool unify(Dictionary <Monomorphic, Monomorphic> m, Monomorphic s, Monomorphic t) { if (s is Slot && t is Slot && s.applySub(m).Equals(t.applySub(m))) { return(true); } else if (s is Primitive && t is Primitive && ((Primitive)s).Name == ((Primitive)t).Name) { return(true); } else if (s is Composite && t is Composite) { var s_ = (Composite)s; var t_ = (Composite)t; return(unify(m, s_.Ctor, t_.Ctor) && unify(m, s_.Argument, t_.Argument)); } else if (s is Slot) { m.Add(s, t); return(true); } else if (t is Slot) { m.Add(t, s); return(true); } else { return(false); } }
public Composite(Monomorphic ctor, Monomorphic argument) { Ctor = ctor; Argument = argument; }
public static Composite Arrow(Monomorphic p, Monomorphic q) { return(ct(ct(pm("[->]"), p), q)); }
public static Composite Product(Monomorphic p, Monomorphic q) { return(ct(ct(pm("[*]"), p), q)); }
public static Composite ct(Monomorphic ctor, Monomorphic argument) { return(new Composite(ctor, argument)); }