Skip to content

Instantly share code, notes, and snippets.

@shajra
Last active August 29, 2015 14:09
Show Gist options
  • Save shajra/08945f37380208bf3db4 to your computer and use it in GitHub Desktop.
Save shajra/08945f37380208bf3db4 to your computer and use it in GitHub Desktop.
Took a while to get Unapply working. . . very open to some code review
case class ProcessMSyntax[F[_], MM[_], A]
(self: Process[F, MM[A]], trav: Traverse[MM]) {
def throughM[MB]
(c: Channel[F, A, MB])
(implicit
uBindB: Unapply[Bind, MB] { type M[X] = MM[X] })
: Process[F, uBindB.M[uBindB.A]] = {
val substC = uBindB.leibniz.subst[Channel[F, A, ?]](c)
ProcessFunctions.throughChannelM(self, substC)(uBindB.TC, trav)
}
}
implicit def processSyntax[F[_], MA]
(p: Process[F, MA])
(implicit ev: Unapply[Traverse, MA])
: ProcessMSyntax[F, ev.M, ev.A] =
ProcessMSyntax(ev.leibniz.subst[Process[F, ?]](p), ev.TC)
// This implicit seems to need to be in scope at the call site
implicit def ev[A] = Unapply[Bind, StreamFault \/ A]
ReadDomains
.process(timestamp, domainFn)(builtwithOutput)
.throughM(WriteSSTables.channel(dir, sql, keyspace, table))
.run
.liftM[ActionT]
Here's the error (cleaned up a bit) I get if I don't have the implicit in scope:
[error] could not find implicit value for parameter uBindB:
Unapply[Bind, StreamFault \/ Unit] { type M[X] = StreamFault \/ X }
[error] .throughM(WriteSSTables.channel(dir, sql, keyspace, table))
[error] ^
[error] one error found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment