title: GADT for polymorphic list
body: <p>I am parsing a few statements of the form</p>
  
  <pre><code>v1 = expression1
  v2 = expression2
  ...
  </code></pre>
  
  <p>I am using the State Monad and my state should be a pair of (String, Expr a), I really insist on having the expressions typed. I tried to implement the state as [PPair] where I define PPair by the GADT:</p>
  
  <pre><code>data PPair where
      PPair :: (String, Expr a) -&gt; PPair
  </code></pre>
  
  <p>Once this line passed the compiler, I felt that I am doing something really really wrong. I suppressed the thought and went on coding. When I came to writing the code that would extract the value of the variable from the State, I realized the problem:</p>
  
  <pre><code>evalVar k ((PPair (kk, v)):s) = if k == kk then v else evalVar k s
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>Inferred type is less polymorphic than expected
  </code></pre>
  
  <p>which is quite expected. How do I work around this problem? I know I can solve it by breaking up the type over all candidate types a, but is there no neater way?</p>