Created
November 12, 2017 22:11
-
-
Save mandubian/3eb1552b984a0fec7cde22a5e744857e 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
implicit val Function1ClosedCartesianCat: ClosedCartesianCat[Function1] = new ClosedCartesianCat[Function1] { | |
def id[A]: A => A = identity | |
def ○[A, B, C]: (B => C) => (A => B) => (A => C) = f => g => f compose g | |
def ⨂[A, C, D]: (A => C) => (A => D) => (A => (C, D)) = f => g => (a => (f(a), g(a))) | |
def exl[A, B]: ((A, B)) => A = _._1 | |
def exr[A, B]: ((A, B)) => B = _._2 | |
def it[A]: A => Unit = _ => () | |
def ap[A, B]: ((A => B, A)) => B = f => f._1(f._2) | |
def curry[A, B, C]: (((A, B)) => C) => (A => (B => C)) = f => a => (b => f((a, b))) | |
def uncurry[A, B, C]: (A => (B => C)) => (((A, B)) => C) = f => { case (a, b) => f(a)(b) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment