Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
Created August 6, 2018 19:36
Show Gist options
  • Save kevinmeredith/38b59e8f42627b710b3e220283553409 to your computer and use it in GitHub Desktop.
Save kevinmeredith/38b59e8f42627b710b3e220283553409 to your computer and use it in GitHub Desktop.
Understanding Kleisli |||
@ val x: Kleisli[Task, String \/ Int, Boolean] = Kleisli {
    case -\/(_) => Task.now(true)
    case \/-(_) => Task.now(false)
  } 
x: Kleisli[Task, String \/ Int, Boolean] = Kleisli(ammonite.$sess.cmd5$$$Lambda$2811/243334301@38171f9)

@ val x: Kleisli[Task, String, Boolean] = Kleisli { _ => Task.now(true) } 
x: Kleisli[Task, String, Boolean] = Kleisli(ammonite.$sess.cmd6$$$Lambda$2832/1335778574@1bde703a)

@ val y: Kleisli[Task, Int, Boolean] = Kleisli { _ => Task.now(false) } 
y: Kleisli[Task, Int, Boolean] = Kleisli(ammonite.$sess.cmd7$$$Lambda$2841/275347188@4e1cc48b)

@ val input: String \/ Int = \/-(42) 
input: String \/ Int = \/-(42)

@ (x ||| y)(input) 
res9: Task[Boolean] = scalaz.concurrent.Task@5e952f27

@ (x ||| y)(input).unsafePerformSync 
res10: Boolean = false

@ (x ||| y)(-\/("foo")).unsafePerformSync 
res11: Boolean = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment