Created
February 25, 2020 09:43
-
-
Save diversit/8cf6ba39a5f67d24a6c57fdc2c16d839 to your computer and use it in GitHub Desktop.
Thrust operator to move monad conversion to right to get more readable code
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
package utils | |
/** | |
* From 'How to unsuck Future[Option[T]]' by Erik Bakker. | |
* Operator taken from Scalaz which allow to specify a function in a different order. | |
* | |
* This operator allows to move transformations in for-comprehension to the right | |
* which makes the code easier to read. | |
*/ | |
object ThrushOperator { | |
implicit class ThrushOperator[A](val a: A) extends AnyVal { | |
def |>[B](f: A => B) = f(a) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment