title: Haskell pattern match on type
body: <p>Is there any way of doing something like this in haskell ?</p>
  
  <pre><code>data Fruits = Apple Int | Orange Int deriving (Eq, Show)
  
  basket = [Apple 2, Orange 4]
  
  from_basket t (x:basket) =
      case x of
          (t i) -&gt; i
          _ -&gt; from_basket t basket
  </code></pre>
  
  <p>Now i want to get the 'apple' from the list of fruits ( basket )</p>
  
  <pre><code>from_basket Apple basket
  </code></pre>
  
  <p>Without an explicit pattern match</p>
  
  <pre><code>case x of
      Apple i -&gt; ...
      Orange i -&gt; ...
      _ -&gt;
  </code></pre>