Skip to content

Instantly share code, notes, and snippets.

@stephen-lazaro
Last active November 9, 2018 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephen-lazaro/15bc15da3ad27e33857f704eacc49657 to your computer and use it in GitHub Desktop.
Save stephen-lazaro/15bc15da3ad27e33857f704eacc49657 to your computer and use it in GitHub Desktop.
def map2[F[_]: Monoidal, A, B, C](fa: F[A], fb: F[B])(f: (A, B) => C): F[C] =
  Monoidal[F].map(Monoidal[F].product(fa, fb))(f.tupled)
def map3[F[_]: Monoidal](fa: F[A], fb: F[B], fc: F[C])(f: (A, B, C) => D): F[D] =
  Monoidal[F].map(
  Monoidal[F].product(Monoidal[F].product(fa, fb), fc))
  )({
  case ((a, b), c) => f(a, b, c)
  })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment