Created
October 3, 2015 16:42
-
-
Save ryasmi/6333e0be42b59d7295da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
abstract = (argTypes..., retType) -> (value) -> | |
val = (args...) -> | |
args.forEach((arg, index) -> | |
if arg.constructor isnt argTypes[index] | |
throw new Error('Invalid arg') | |
) | |
ret = value(args...) | |
if ret.constructor isnt retType | |
throw new Error('Invalid ret') | |
ret | |
val.type = arguments.callee | |
val | |
move = abstract(String) | |
#ride = move () -> 10 | |
ride = move () -> 'ride' | |
Vehicle = abstract(Object) | |
Bicycle = Vehicle () -> | |
move: ride | |
#alert(Bicycle.type is Vehicle) | |
#alert(ride('sfsdf')) | |
alert(ride()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment