Created
June 12, 2019 02:26
-
-
Save joseoliv/0c28cfaa5a50bef0462a3cfae297687c to your computer and use it in GitHub Desktop.
prototype that uses annotation concept
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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