Last active
June 17, 2018 01:16
-
-
Save jdoiwork/579211b511d18d76ba5c 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
| class Nothing | |
| constructor: () -> | |
| bind: (f) -> | |
| @ | |
| class Just | |
| constructor: (b) -> | |
| @just = b | |
| bind: (f) -> | |
| f @just | |
| class Left | |
| constructor: (a) -> | |
| @error = a | |
| bind: (f) -> | |
| @ | |
| class Right | |
| constructor: (b) -> | |
| @right = b | |
| bind: (f) -> | |
| f @right | |
| r1 = new Right("tanaka") | |
| console.log "case ", r1.right | |
| hontoWaSakao = (name) -> | |
| new Right("sakao") | |
| eitherRakusu = (name) -> | |
| if name == "tanaka" | |
| new Right(name) | |
| else | |
| new Left("rakusu jana-i") | |
| killRakusu = (name) -> | |
| console.log "yahho ^^" | |
| r1 | |
| .bind(hontoWaSakao) | |
| .bind(eitherRakusu) | |
| .bind(killRakusu) | |
| .bind(doNanka1) | |
| .bind(doNanka2) | |
| .bind(doNanka3) | |
| console.log "owari" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment