Can extractors be customized with parameters in the body of a case statement (or anywhere else that an extractor would be used)?

Parameterising extractors would be cool, but we don't have the resources to implement them right now.


Nope.

8.1.7 Extractor Patterns

An extractor pattern x (p 1 , . . . , p n ) where n ≥ 0 is of the same syntactic form as a constructor pattern. However, instead of a case class, the stable identifier x denotes an object which has a member method named unapply or unapplySeq that matches the pattern.


Late but there is a scalac plugin in one of my lib providing syntax ~(extractorWith(param), bindings):

x match {
  case ~(parametrizedExtractor(param)) => 
    "no binding"
  case ~(parametrizedExtractor(param), (a, b)) =>
    s"extracted bindings: $a, $b"
}

https://github.com/cchantep/acolyte/blob/master/scalac-plugin/readme.md