Last active
August 29, 2015 14:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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