And here's the cool one:
var r = a * c * c * c + b * c * c + d * c + e;
reduces to (actual generated code):
PTF r = ((PTF a * PTF c + PTF b ) * PTF c + PTF d ) * PTF c + PTF e ;
Seems we need 'dependent typing' or something to do this one tho:
var r = a * c ^ 3 + + b * c ^ 2 + d * c + e;
/
#import
type INT = "int";
fun INTOF: int -> INT = "$1";
typeclass ADD[t] {
virtual fun add: t * t -> t;
virtual fun mul: t * t -> t;
reduce ASS(x:t, y:t, z:t): x * z + y * z => (x + y) * z;
}
instance ADD[INT] {
fun add: INT * INT -> INT = "$1+$2";
fun mu