Skip to content

Instantly share code, notes, and snippets.

@jdoiwork
Last active June 17, 2018 01:16
Show Gist options
  • Select an option

  • Save jdoiwork/579211b511d18d76ba5c to your computer and use it in GitHub Desktop.

Select an option

Save jdoiwork/579211b511d18d76ba5c to your computer and use it in GitHub Desktop.
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