That title could be simplified, but its what i'm trying to do.
example and i'm not going to post all the bad code i've tried....but enough to give you a taste of my thought process.
case class User(user:Int)
case class Foo(bar:String)
def parseRequest[T,V](classModel : T): V = {
val parsed = Try(requestBody.extract[classModel]) //request is an implicit an in scope.
parsed match {
case Failure(e) => doExceptionHanldingThatExits(e)
case Success(_) =>
}
parsed.get
}
val userResult = parseRequest(User) //ohnoes!!!
The issue is that classModel is not known (unknown symbol), Intellij wants me to write it as classModel.type, but then i get an error message like:
[error] found : classModel.type (with underlying type T)
[error] required: AnyRef
[error] Note that T is unbounded, which means AnyRef is not a known parent.
[error] Such types can participate in value classes, but instances
[error] cannot appear in singleton types or in reference comparisons.
I'm not sure that just having it be AnyRef will fully solve my issue as i need to be able to extract data from the result, but getting this to compile to vastly increase my understanding (yes i'm a noob to scala, but digging it!)
Any pointers or assistance is greatly appreciated, this is an area of scala, i'd like to have a much firmer understanding of as it will open many doors and increase DRY :)
Happy Friday (if you're still in a US Timezone)
Thanks,
Jeff