Last active
December 17, 2015 08:08
-
-
Save lihaoyi/5577609 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
case class Thing(s: String){ | |
def :=(t: Thing) = s + ": " + t.s | |
} | |
val float = Thing("float") | |
val left = Thing("left") | |
val backgroundImage = Thing("background-image") | |
def radialGradient(s: String) = Thing(s"radialGradient($s)") | |
val red = Thing("red") | |
val blue = Thing("red") | |
float:=left | |
backgroundImage:=radialGradient(red, blue) | |
case class Thing(s: String){ | |
def :=(t: Thing) = s + ": " + t.s | |
} | |
val float = Thing("float") | |
object Float{ | |
val left = Thing("left") | |
} | |
val backgroundImage = Thing("background-image") | |
object Image{ | |
def radialGradient(s: String) = Thing(s"radialGradient($s)") | |
} | |
object Color{ | |
val red = Thing("red") | |
val blue = Thing("red") | |
} | |
float:=Float.left | |
backgroundImage:=Image.radialGradient(Color.red, Color.blue) | |
case class Thing(s: String){ | |
def :=(t: Thing) = s + ": " + t.s | |
} | |
object float extends Thing("float"){ | |
val left = this := Thing("left") | |
} | |
val backgroundImage = Thing("background-image") | |
object Image{ | |
def radialGradient(s: Thing*) = Thing(s"radialGradient(${s.mkString(',')})") | |
} | |
object Color{ | |
val red = Thing("red") | |
val blue = Thing("red") | |
} | |
float:=Float.left | |
backgroundImage.radialGradient(Color.red, Color.blue) | |
case class Thing[T](s: String){ | |
def :=(t: T => Thing) = s + ": " + t.s | |
} | |
val float = Thing[Float]("float") | |
object Float{ | |
val left = this := Thing("left") | |
} | |
val backgroundImage = Thing[Image]("background-image") | |
object Image{ | |
def radialGradient(s: Thing*) = Thing[Color](s"radialGradient($s)") | |
} | |
object Color{ | |
val red = Thing("red") | |
val blue = Thing("red") | |
} | |
float:=(_.left) | |
backgroundImage:=(_.radialGradient(_.red, _.blue)) | |
float:=left | |
backgroundImage:=radialGradient(red, blue)) | |
object Src{ | |
val stuff | |
} | |
func(thunk: @binds[Src.type] => T) = { | |
... thunk(Src) ... // thunk itself has a type Src.type => T | |
} | |
// but at the callsite, does some magic, like magic stuff | |
// scoped lexically to that argument | |
func("" + stuff) | |
// because it basically desugars into | |
func({ $src => | |
import $src._ | |
"" + stuff | |
}) | |
Events.loop[B] { self => | |
val es = loopUntil(outer) { | |
self << (self await inner) | |
self.pause | |
} | |
inner = isEvents(es) | |
} | |
Events.loop[B] { self => | |
val es = loopUntil(outer) { | |
<< (await inner) | |
pause | |
} | |
inner = isEvents(es) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment