shithub: mc

ref: ff88594df5c5df6fb8f227ab8e5df3529ba6e72f
dir: /test/traitimpl.myr/

View raw version
use std

trait frobable @a =
	frob	: (val : @a -> @a)
;;

impl frobable int =
	frob = {val
		-> val * 2
	}
;;

impl frobable int16 =
	frob = {val
		-> val * 4
	}
;;

impl frobable byte[:] =
	frob = {val
		-> val[:4]
	}
;;

generic foo = {x : @a :: frobable @a
	-> frob(x)
}

const main = {
	var a, b, c
	a = foo(123)
	b = foo((11 : int16))
	c = frob("meeeeeeh")
	std.put("{},{},{}\n", a, b, c)
}