Paste: clay interfaces

Author: j
Mode: text
Date: Sat, 24 Apr 2010 08:18:04
Plain Text |
overloadable zim;
overloadable zang;

zim(x:Int, y:Int) : Int = x + y;
zang(x:Double, y:Double, z:Double) : Double = x + y + z;

zim(x:String, y:Int) : Int = y * 2;
zang(x:String, y:Double, z:Double) : Double = y - z;

static TestInterface = Interface[
    Tuple[zim, Int, Int],
    Tuple[zang, Double, Double, Double],
];

frob(x:Box[TestInterface]) = zim(x, Int(zang(x, 2.0, 3.0)));

main() {
    x = box(TestInterface, 3);
    y = box(TestInterface, "foo");

    println(frob(x));
    println(frob(y));
}

New Annotation

Summary:
Author:
Mode:
Body: