Created
March 22, 2016 14:23
-
-
Save sam/0e2e81d4e3dad67dc451 to your computer and use it in GitHub Desktop.
Trying to figure out how I can zip both 1-arg functions, and no-arg functions for use in ScalaTest test-fixture "loan" functions.
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
type FixtureFunction[T] = T => Any | |
implicit class FixtureFunctionZipper[A](f1: FixtureFunction[A] => Any) { | |
def zip[B](f2: FixtureFunction[B] => Any): ((A, B) => Any) => Any = { test => | |
f1(a => f2(b => test(a, b))) | |
} | |
def zip(f2: (Unit => Any) => Any): (A => Any) => Any = { test => | |
f1(a => f2(_ => test(a))) | |
} | |
} | |
implicit class CBNFixtureFunctionZipper(f1: (Unit => Any) => Any) { | |
def zip[A](f2: FixtureFunction[A] => Any): (A => Any) => Any = { test => | |
f1(_ => f2(test)) | |
} | |
def zip(f2: => (Unit => Any) => Any): (=> Any) => Any = { test => | |
f1(_ => f2(_ => test)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment