title: Is is possible to refer to Type Variables in pattern matching?
body: <p>The following code (which is not meant to do anything useful) compiles fine : </p>
  
  <pre><code>{-# LANGUAGE ScopedTypeVariables #-}
  import System.Random
  
  uselessFunction :: (RandomGen g) =&gt; g -&gt; [Int]
  uselessFunction gen = 
    let (value::Int, newGen) = (random gen)
    in (uselessFunction newGen)
  </code></pre>
  
  <p>Is it possible for me to use type variables in the pattern matching, in the following spirit (code fails to compile): </p>
  
  <pre><code>{-# LANGUAGE ScopedTypeVariables #-}
  import System.Random
  
  uselessFunction :: (RandomGen g, Random a) =&gt; g -&gt; [a]
  uselessFunction gen = 
    let (value::a, newGen) = (random gen)
    in (uselessFunction newGen)
  </code></pre>