-
-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Labels
Description
@refried originally filed as playframework/playframework#2194. migrating it here
views/foo1.scala.txt (won't compile)
@[L<:shapeless.Nat:shapeless.ops.nat.ToInt](bar: Bar[L])
@bar has size @shapeless.Nat.toInt[L]
views/foo2.scala.txt (will compile, but silly!)
@(bar: Bar[_<:shapeless.Nat], size: Int)
@bar has size @size
controllers/Application.scala
package controllers
import play.api._
import play.api.mvc._
import shapeless.Nat
import shapeless.ops.nat.ToInt
class Bar[L<:Nat]
object Application extends Controller {
def index = Action {
Ok(views.html.index("Your new application is ready."))
}
// won't compile
def foo1 = views.txt.foo1(new Bar[Nat._3])
// needlessly complicated
def foo2 = {
def barSize[L<:Nat:ToInt](bar: Bar[L]): Int = Nat.toInt[L]
val bar = new Bar[Nat._3]
val size = barSize(bar)
views.txt.foo2(bar, size)
}
}mattfeury, ewiner, EnverOsmanov, jamesward, resamsel and 1 more