Skip to content

Instantly share code, notes, and snippets.

@jeantil
Created February 8, 2013 13:16
Show Gist options
  • Save jeantil/4738988 to your computer and use it in GitHub Desktop.
Save jeantil/4738988 to your computer and use it in GitHub Desktop.
import org.specs2.mutable._
class ImplicitiSpec extends Specification {
type Store=Map[String,String]
object Value {
def apply(k:String)(implicit map:Store):String={
println(s"reads value for ${k}")
map.get(k).getOrElse("")
}
}
trait A {
lazy val a:String= ??? // Value("a") ...
}
object B extends A
"An Implicit" should {
"be propagated " in{
// If I knew how to code properly this would compile and work
implicit val m=Map("a"->"aa")
B.a === "aa"
}
}
}
@fsarradin
Copy link

@un-jon you would convert lazy val into ìmplicit def`?

@jeantil I don't know why it sounds like the Reader monad?...

@jeantil
Copy link
Author

jeantil commented Feb 12, 2013

I don't get it :( I'll submit it to the psug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment