Skip to content

Instantly share code, notes, and snippets.

@tomaszperek
Created October 19, 2015 21:46
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 tomaszperek/7917f660173a37c0950b to your computer and use it in GitHub Desktop.
Save tomaszperek/7917f660173a37c0950b to your computer and use it in GitHub Desktop.
Implementation of hsequence and zip for Monads
def hsequence[M[_], In <: HList, Out <: HList](l: In)(implicit ev: IsHListOfM[M, In, Out], m: Monad[M]) = ev.hsequence(l)
def zip[M[_], P <: Product, In <: HList, Out <: HList]
(p: P)
(implicit gen: Generic.Aux[P, In], ev: IsHListOfM[M, In, Out], tupler: Tupler[Out], m: Monad[M]) = {
m.map(hsequence(gen.to(p)))(_.tupled)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment