score:0
I got it working as following
type C1Str[M] = M match {
case Int => Int
case String => Int
}
type C1Int[M] = M match {
case String => Int
}
type C2[N, M] = N match {
case String => C1Str[M]
case Int => C1Int[M]
}
def fn[M,N](x:N,y:M):C2[N,M] = x match {
case x: String => y match {
case y: Int => x.size + y
case y: String => x.size + y.size
}
case x: Int => y match {
case y: String => x + y.size
}
}
It looks if you want to create a match type with multiple type parameters you need to make each case another match type.
Source: stackoverflow.com
Related Query
- How to get match type with multiple type parameters to work correctly in Scala 3
- How to get match type to work correctly in Scala 3
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- How do you create scala anonymous function with multiple implicit parameters
- scala pattern match a function - how to get around type erasure
- Scala - how come using a super-type with two generic parameters cause the scala type checker to treat the child-type differently?
- How can I get Scala Named and Default arguments to work with macros
- How do I get type parameter from type with type parameter, inside scala macro?
- How to get a method return type with scala meta annotation?
- How to make a function to work with a collection of any Numeric type in Scala
- Question about Scala implicits with multiple type parameters
- How do I get the type signature to agree with the scala compiler when extracting a value out of an Option[A]?
- How to get underlying constant type from singleton type with Scala reflection API
- How to apply a customized function with multiple parameters to each group of a dataframe and union the resulting dataframes in Scala Spark?
- How do I get the class object of Class with type parameters in Scala?
- how match mixed type of scala higher-kinder types feature with java generic type?
- How to match scala generic type with trait
- How to get manifest from string representation for type with parameters
- How to compose partial functions with multiple parameters in Scala
- How Scala allows overriding with type parameters and not with type class
- How to get a type with parameters inside the base class
- How to work with abstract type members in Scala
- Scala For Comprehension - how does it work with multiple arguments that involves variable assignments?
- How to use TypeTag correctly if the type to match also takes type parameters
- How to get multiple adjacent data in a RDD with Scala Spark
- Scala type keyword: how best to use it across multiple classes
- How the get the classOf for a scala object type
- How can Scala receive multiple parameters in a method definition?
- How to get logging working in scala unit tests with testng, slf4s, and logback
- How to pattern match a class with multiple argument lists?
More Query from same tag
- Spark 1.6: Exception when saving DataFrame into Hive
- Decode gzipped JSON in Akka HTTP
- Passing arguments with parentheses to Scala script contained in windows batch file
- Scala code doesnt fetch s3 file
- Convert Spark Row to typed Array of Doubles
- Why can't websockets with iteratees supply separate types for the input frames and output frames?
- Redirect stdout in another thread
- spark dataframe to be written in partitions
- Scala Random String
- how to map each row of a scala dataframe to a new schema
- Why doesn't this pattern matching work as expected in Scala?
- Scala reading file with Spark
- Typesafe Hierarchichal Structure
- How to setup RabbitMQ consumer in Spark
- How to write tests for a Play Framework Filter?
- Element-wise sum of arrays in Scala
- Scala - how to filter fields from nested classes?
- How to merge a keySet of a Map with each List Element : Scala
- How to make method return type covariant
- Scala List difference with index information
- match a String based on regex pattern matching scala
- Percentile over a specific column
- Implicit conversion for multiple parameters
- Scala Play Forms: using HLists to get around the 22 fields limitation
- Using Java 8 in Scala 2.11
- Scala class file broken error over Java jar
- Spark Scala [for loop embedded with if-else] how can I not receive duplicate array
- Scala map a Vector of tuples to vector of object
- How to terminate Scala Remote Actor client?
- Scala: AND conjunction in Lists