Last active
July 5, 2016 05:06
-
-
Save benhutchison/72ec37e6d7e206f548b8d044c78f421c to your computer and use it in GitHub Desktop.
Eff: Can a Member type that takes a type parameter be expressed as a context bound of the effect type?
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
~$> ./amm | |
Loading... | |
Welcome to the Ammonite Repl 0.6.2 | |
(Scala 2.11.8 Java 1.8.0_51) | |
@ load.plugin.ivy("org.spire-math" %% "kind-projector" % "0.8.0") | |
@ load.ivy(("org.atnos" %% "eff-cats" % "1.7.4")) | |
@ import cats.data._ | |
import cats.data._ | |
@ import org.atnos.eff.all._ | |
import org.atnos.eff.all._ | |
@ import org.atnos.eff._ | |
import org.atnos.eff._ | |
@ type Err[R] = Member[Xor[String, ?], R] | |
defined type Err | |
@ def generic[C, R: Err](contextOp: C => Eff[R, (Int, C)])(implicit s: State[C, ?] <= R): Eff[R, Int] = for { | |
c <- get[R, C] | |
result <- contextOp(c) | |
(i, c2) = result | |
_ <- put[R, C](c2) | |
} yield i | |
defined function generic | |
@ //what would it take to write the Member for State[C, ?] as a context boud, parameterized on C ?? | |
@ type S[C] = Member[State[C, ?], ?] | |
cmd8.scala:1: type Λ$ takes type parameters | |
type S[C] = Member[State[C, ?], ?] | |
^ | |
Compilation Failed | |
@ //The Member type has ~two~ holes in it, the righthand of which must be associated with the context bound | |
@ //What we'd like is: C => R => Member[State[C, ?], R] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment