Search code examples
scalamonadsfor-comprehension

Warning:(55, 56) `withFilter' method does not yet exist on MoldPiece[PressureData(Int, prettyprint.YesNo)], using `filter' method instead


Is there a method for switching off that warning? I completely understand what it says, why it is generally helpful and why WithFilter exists, but this particular monad is used to compose individual functions rather than collections of monadic type values, and WithFilter won't provide any meaningful improvement while requiring an additional method and classes confounding the simple interface of the class.


Solution

  • What about defining def withFilter(f: A => Boolean) = filter(f) and documenting it only exists for this purpose? Unfortunately, Scala compiler doesn't have a general way to switch off warnings you don't want and I don't think there is a way specific to this one.