Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
prototype that uses annotation concept
package generic
@concept{*
cyan.lang.init(IntGroupPlus, Int),
cyan.lang.lessThan(IntGroupPlus)
*}
object IntGroupPlus
@init(_elem)
@property var Int _elem;
func * (IntGroupPlus other) -> IntGroupPlus = IntGroupPlus(_elem + other elem);
func unit -> IntGroupPlus = IntGroupPlus(0);
func inverse -> IntGroupPlus = IntGroupPlus(-_elem);
func asInt -> Int = _elem;
override
func == Dyn other -> Boolean {
type other
case IntGroupPlus another {
return _elem == another elem
}
return false;
}
override
func hashCode -> Int = _elem hashCode;
func < IntGroupPlus other -> Boolean = _elem < other asInt;
override
func asString -> String = "IntGroupPlus($_elem)";
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.