Created
March 19, 2015 18:18
-
-
Save crakjie/96c70ce095cc153e478e to your computer and use it in GitHub Desktop.
Hack seq to add scalaz disjonction as operator which make a left when the list is empty
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
import scalaz.{\/, \/- ,-\/} | |
implicit final class SeqOps[A](seq : Seq[A]) { | |
def \/>[T](t : T) : T \/ Seq[A] = if (seq.isEmpty) -\/(t) else \/-(seq) | |
} | |
//usage | |
val right = Seq(1,2) \/> "Oh a nel!" | |
val left = Nil \/> "!#& a Nil !!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment