Skip to content

Instantly share code, notes, and snippets.

@djspiewak
Created January 26, 2020 17:34
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 djspiewak/63abc62712a3089ecf14d9f452bb2255 to your computer and use it in GitHub Desktop.
Save djspiewak/63abc62712a3089ecf14d9f452bb2255 to your computer and use it in GitHub Desktop.
def foldDistributesOverSequence[A: Monoid](fga: F[G[A]]) = {
implicit val mga: Monoid[G[A]] = Applicative.monoid[G, A]
fga.fold <-> fga.sequence.map(_.fold)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment