Created
May 25, 2016 20:48
-
-
Save mrcmatuszak/cee890b1f8a0d0a0cb16f69c3e7b06cf to your computer and use it in GitHub Desktop.
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
object Counter { | |
type CounterState = State[Int, Int] | |
} | |
trait Counter { | |
import Counter._ | |
def inc: CounterState = State { s => (s + 1, s + 1) } | |
} | |
trait Service { | |
self: Counter => | |
import Counter._ | |
var currentCount: Int = ??? | |
def foo: Int = { | |
val s = inc.run(???) | |
currentCount = s.value._1 | |
s.value._2 | |
} | |
} | |
trait Service2 { | |
self: Counter => | |
import Counter._ | |
var currentCount: CounterState = ??? | |
def foo: Int = { | |
val s = inc.run(???) | |
currentCount = s.value._1 | |
s.value._2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment