title: Passing type information to function in Scala
body: <p>I have code that does some common operation on json objects, namely extract. So what I would like to create generic function that takes type parameter which class to expect, code looks like as follows:</p>
  
  <pre><code>def getMessageType[T](json: JValue): Either[GenericError,T] = {
    try {
      Right(json.extract[T])
    } catch {
      case e: MappingException =&gt; jsonToError(json)
    }
  }
  </code></pre>
  
  <p>The issue is how to pass T information to that function ?</p>