question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no type arguments for views?

See original GitHub issue

@refried originally filed as https://github.com/playframework/playframework/issues/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)
  }
}

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:6
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
julienrfcommented, Apr 6, 2016

Hi, FWIW, a workaround is to use the string interpolator:

import play.twirl.api.StringInterpolation

def foo[L <: Nat : ToInt](bar: Bar[L]): Html =
  html"$bar has size ${Nat.toInt[L]}"
0reactions
mkurzcommented, Nov 10, 2018

Related #153

Read more comments on GitHub >

github_iconTop Results From Across the Web

No type arguments expected for fun findViewById(p0: Int): View
i tried to declare an imageView on Kotlin like this : view.findViewById<ImageView>(R.
Read more >
No type arguments expected for fun findViewById(p0: Int): View!
No type arguments expected for fun findViewById(p0: Int): View! ; Project, Kotlin ; Priority, Not specified ; Type, Bug B ; Target versions,...
Read more >
Type '<typename>' has no type parameters and so cannot ...
Non -generic types do not accept type parameters, and you cannot specify any type arguments when you invoke such a type. Error ID:...
Read more >
PEP 484 – Type Hints - Python Enhancement Proposals
It is recommended but not required that checked functions have annotations for all arguments and the return type. For a checked function, the...
Read more >
Pass data between destinations - Android Developers
Supported argument types; Override a destination argument in an ... Click the Text tab to toggle to XML view, and notice that your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found