score:4
Accepted answer
Shapeless tries to remove precisely type b.type
but can't find it among Container["A"] :: Container["B"] :: Container["C"] :: HNil
so @user is correct, singleton type b.type
is too specific.
In order to infer an HList
type from a val
singleton type try to modify the method
implicit class RemoveAllOps[L <: HList](a: L) {
def removeAll[L1 <: HList](b: L1)(implicit
ra: shapeless.ops.hlist.RemoveAll[L, L1]
): ra.Out = ra(a)
}
a.removeAll(b) // (Container(B) :: Container(C) :: HNil,Container(A) :: HNil)
or
implicit class RemoveAllOps[L <: HList](a: L) {
def removeAllFrom[O <: Singleton] = new {
def apply[L1 >: O <: HList]()(implicit
ra: shapeless.ops.hlist.RemoveAll[L, L1]
): ra.Out = ra(a)
}
}
a.removeAllFrom[b.type]() //(Container(B) :: Container(C) :: HNil,Container(A) :: HNil)
Source: stackoverflow.com
Related Query
- Is there a way to use the type of an object as the argument of a type parameter?
- Is there are way to create a generic class with a trait or mixin that is a subtype of the type parameter
- Is there a way to use the '+' operator as addition on parameters passed to a method as a generic type in Scala?
- What's the standard way to work with dates and times in Scala? Should I use Java types or there are native Scala alternatives?
- Is there a way to specify a subset of type parameters in Scala, inferring the rest?
- In Scala is there a way to reference the Companion Object from within an instance of a Case Class?
- Is there a way to match on a call-by-name argument of a Mockito mock object in Specs?
- Is there a reason to use subtype as type parameter in Scala?
- Is there a way to use the Scala 3 compiler (Dotty) from Gradle yet?
- Is there a way to extract the item type from a Manifest[List[X]] in Scala?
- Is there a way to call a function defined using `val` in Scala with the whole curly brace block as an argument and not the final result of that block?
- What is the correct way to specify type variance for methods in a companion object
- Is there a way to specify the return type of an Scala function literal?
- Scala: What is the type of a function object that takes two parameter lists?
- Scala: Is there a way where type aliases can be treated as distinct from the type that they alias?
- Why can't the compiler infer type parameter for package object (while it works fine for object)?
- What's the use and meaning of second type parameter in akka.Source
- Is there a way to avoid repeating the type parameters when using a trait?
- Is there a way to stop Scala 2.12 breaking the Jackson object mapper?
- Is there any way of calling scala method (having type parameter ) with infix notation
- Is there an idiomatic way to convert a Class to an Object when the class relies on an implicit?
- missing parameter type for expanded function The argument types of an anonymous function must be fully known. (SLS 8.5) Expected type was:?
- In Scala is there a way to specify that the return type should match the type of the method caller?
- Type constraints on the companion object of a type parameter in scala
- Is there a way to expand the scope of an existential type quantifier in Scala to convince the type checker that two variables have the same type?
- Is there a way to override the default object printing
- Is there a straightforward and general way to wrap a scala object's code with code to be executed before and after the object body code?
- Converting object of type Any into myClass, by passing the myClass as parameter
- scala: missing parameter type for expanded function: the argument types of an anonymous function must be fully known
- Is there any way to use immutable collections here + make the code look better?
More Query from same tag
- Compiling Spark Scala Program into jar file using installed spark and maven
- How to put values to the new separate DataFrame columns based on the value of specific already existing column? I.e transpose the DataFrame
- Replace scalaz ListT with semantically equivalent cats functionality
- sbt package not adding dependencies
- Scala - bad constant pool tag
- Scala DataFrame - How to only print rows with largest values
- Field autoincrement for Oracle without trigger with Slick?
- Extracting Raw JSON as String inside a Spray POST route
- Spark: group only part of the rows in a DataFrame
- Spark Kafka connection failed : No resolvable bootstrap urls given in bootstrap.servers
- How can I add jars from more than one unmanaged directory in an SBT .scala project configuration
- Error while using sbt-native-packager to get the docker support for my sbt project
- Scala DataFrameReader Keep column headers
- Scala annotation macro only works with pre-defined classes
- Why does adding a "pending" break my Scala test?
- Update Scala Slick rows with optional columns
- Apply 'rlike' on a regex column?
- How to make the "run" button automatically launch the project with specified configuration
- Combine 2 vectors of a custom type to return 1 vector
- Why this scala code reports compilation error: recursive value x needs type
- a better way to create a map from a list
- Bug in Scala 2.10, Iterator.size?
- Mahout spark-shell Initial job has not accepted any resources
- Scala Type Classes Best Practices
- extracting sub string using pattern matching in scala
- Making a partial function complete
- How to call Map functions on object that returns Map with type Any in Scala
- Choose root DNS server to use
- How to keep all elements when aggregating on AggregateMessages on a GraphFrame?
- How to investigate objects/types/etc. from Scala REPL?