Last active
December 8, 2015 09:57
-
-
Save rahilb/9880c932a6b7075c03c0 to your computer and use it in GitHub Desktop.
Scalaz solutions for scala warts
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
import scalaz._ | |
import Scalaz._ | |
// Option#getOrElse is ugly | |
val two = None | 2 | |
// if else & bool match are ugly | |
val three = true.fold(t = 3, f = 0) | |
// nested method calls can become ugly & hard to read | |
scala> def dub(i: Int) = i * 2 | |
scala> def trip(i: Int) = i * 3 | |
// ugly! | |
scala> trip(trip(dub(1))) | |
res2: Int = 18 | |
// awesome! | |
scala> 1 |> dub |> trip |> trip | |
res3: Int = 18 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment