Last active
August 29, 2015 14:01
-
-
Save aryairani/95b18658426c7cc09390 to your computer and use it in GitHub Desktop.
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
object Foo { | |
def given[A,B,C,S](aa: S => Stream[A], | |
bb: S => Stream[B], | |
cc: S => Stream[C]) = new { | |
def thereExists(f: (A,B,C)=>Boolean)(s: S): Boolean = { | |
val cross = for { | |
a <- aa(s) | |
b <- bb(s) | |
c <- cc(s) | |
} yield f(a,b,c) | |
cross.exists(identity) | |
} | |
} | |
import scalaz.syntax.applicative._ | |
import scalaz.std.stream._ | |
import scalaz.syntax.foldable._ | |
import scalaz.Tags.Disjunction | |
def given[A,B,C,D,S](aa: S => Stream[A], | |
bb: S => Stream[B], | |
cc: S => Stream[C], | |
dd: S => Stream[D]) = new { | |
def thereExists(f: (A,B,C,D)=>Boolean)(s: S): Boolean = | |
^^^(aa(s),bb(s),cc(s),dd(s))(f).foldMap(Disjunction)// lift f to Stream | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment