title: RankNTypes and pattern matching
body: <p>Is there a way in haskell to erase type information/downcast to a polymorphic value ?</p>
  
  <p>In the example I have a boxed type T which can contain either an Int or a Char
  And I want to write a function which extract this value without knowing which type it is.</p>
  
  <pre><code>{#- LANGUAGE RankNTypes -#}
  
  data T = I Int | C Char
  
  -- This is not working because GHC cannot bind "a"
  -- with specific type Int and Char at the same time. 
  -- I just want a polymorphic value back ;(
  getValue :: T -&gt; (forall a. a)
  getValue (I val) = val
  getValue (C val) = val
  
  -- This on the other hand works, because the function
  -- is local to the pattern matching expression
  onValue :: T -&gt; (forall a. a -&gt; a) -&gt; T
  onValue (I val) f = I $ f val 
  onValue (C val) f = C $ f val
  </code></pre>
  
  <p>Is there a way to write a function that can extract this value without forcing a type at the end ?</p>
  
  <p>a getValue function like the first one ?</p>
  
  <p>Let me know if it is not clear enough.</p>
  
  <h1>Answer</h1>
  
  <p>So the question was stupid as AndrewC (in the comment) and YellPika pointed out. An infinite type has no meaning.</p>
  
  <p>J. Abrahamson provides an explanation for what I am looking for, so I put his answer as the solution.</p>
  
  <p>P.S: I do not want to use GADT as I do not want a new type each time. </p>