Skip to content

Instantly share code, notes, and snippets.

@joseoliv
Created June 12, 2019 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseoliv/0c28cfaa5a50bef0462a3cfae297687c to your computer and use it in GitHub Desktop.
Save joseoliv/0c28cfaa5a50bef0462a3cfae297687c to your computer and use it in GitHub Desktop.
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