<p>The real way out of this is described in <a href="https://arxiv.org/abs/1806.03476" rel="nofollow noreferrer"><em>Type Variables in Patterns</em>, by Richard A. Eisenberg, Joachim Breitner, Simon Peyton Jones</a>:</p>

<blockquote>
  <p>For many years, GHC has implemented an extension to Haskell that
  allows type variables to be bound in type signatures and patterns, and
  to scope over terms. This extension was never properly specified. We
  rectify that oversight here. With the formal specification in hand,
  the otherwise-labyrinthine path toward a design for binding type
  variables in patterns becomes blindingly clear. We thus extend
  ScopedTypeVariables to bind type variables explicitly, obviating the
  Proxy workaround to the dustbin of history.</p>
</blockquote>
Is is possible to refer to Type Variables in pattern matching?
<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>