Skip to content

Instantly share code, notes, and snippets.

@channingwalton
Created January 22, 2013 20:57
Show Gist options
  • Save channingwalton/4598348 to your computer and use it in GitHub Desktop.
Save channingwalton/4598348 to your computer and use it in GitHub Desktop.
Not cake
trait FooComponent {
def bar: BarComponent#Bar
case class Foo(foofy: String)
}
trait BarComponent {
def foo: FooComponent#Foo
case class Bar(bah: String)
}
object System extends App with FooComponent with BarComponent {
val foo = Foo("foo")
val bar = Bar("bar")
println(s"${foo.foofy} and ${bar.bah}")
}
@channingwalton
Copy link
Author

So, what can cake do that this can't?

  1. Clever type things (path dependent types?)
  2. avoid name clashes between components
  3. cake declares the component's instance in the component, so its local
  4. The above declares dependencies through an abstract def, cake uses self types so the component itself declares its dependencies - not sure what that really means

What else?

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