Skip to content

Instantly share code, notes, and snippets.

@vmarquez
Last active August 29, 2015 14:11
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 vmarquez/c8c59212cc47aca200c9 to your computer and use it in GitHub Desktop.
Save vmarquez/c8c59212cc47aca200c9 to your computer and use it in GitHub Desktop.
def sepSeq[A, B, F[_], G[_]](g: G[EitherT[F, A, B]])(implicit F: Monad[F], G: Foldable[G], M: MonadPlus[G]): EitherT[F, A, (G[A],G[B])] =
EitherT(G.foldRight(g, F.point((M.empty[A],M.empty[B])))( (a, l) =>
for {
tup <- l
e <- a.run
} yield
e.fold(le => (M.plus(M.point(le),tup._1), tup._2), re => (tup._1, M.plus(M.point(re), tup._2)))
).map(_.right[A])
)
@vmarquez
Copy link
Author

Looks to be a type lambda issue, if I have a type alias the issue goes away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment