title: Pattern-matching: split code with PartialFunction?
body: <p>I'm struggling to achieve a "simple" behaviour: divide pattern matching code in two separate functions. </p>
  
  <p>I'm simplifying the model for clearness purpose:</p>
  
  <pre><code>abstract class Animal
  case object Dog extends Animal
  case object Cat extends Animal
  case object Bird extends Animal
  case object Bat extends Animal
  case object Dolphin extends Animal
  </code></pre>
  
  <p>I want to pattern match on these on different functions (because the actual code is pretty long), but there are other arguments so PartialFunctions are giving me the sick...<br>
  In a perfect world I could write : </p>
  
  <pre><code>type PF = PartialFunction[(Animal, Int, String), String] 
  private def processFlying(a: Animal, n: Int, loc: String): PF = {
    a match {
      case Bird =&gt; n + " birds found in " + loc
      case Bat =&gt; n + " bats found in " + underground(loc)
    }
  }
  private def processMarine(a: Animal, n: Int, loc: String): PF = {
    a match {
      case Dolphin =&gt; n + " dolphins found in " + submarine(loc)
    }
  }
  private def processPet(a: Animal, n: Int, loc: String): PF = {
    a match {
      case Dog =&gt; n + " dogs found in " + loc
      case Cat =&gt; n + " cats found in " + loc
    }
  }
  def processAnimal(a: Animal, number: Int, location: String) = {
    val processAll = processFlying orElse processMarine orElse processPet
    processAll(a, n, location)
  }
  </code></pre>
  
  <p>However that does not work. Mostly because I need several argument in my functions. "Why U no use tuples?" would you say? Well I tried and the compiler won't stop complaining the expected type is different than actual type, and different to my alias :(</p>
  
  <p>Any help, tips, or alternative ides will be useful!<br>
  Cheers</p>
  
  <hr>
  
  <p>EDIT: 
  I followed Cyrille's answer bu I also need to perform some work before the match, like this:  </p>
  
  <pre><code>val processFlying: PF = {
    // doSomething, like declare a sub-function f
    {
        case (b: Bird, n, loc) =&gt; f(b)
        case (b: Bat, n, loc) =&gt; f(b)
    }
  }
  </code></pre>