title: How to create a generic Complex type in haskell?
body: <p>I want to create a Complex type to represent complex numbers.</p>
  
  <p>Following works:</p>
  
  <pre><code>Prelude&gt; data Complex = Complex Int Int
  
  Prelude&gt; :t Complex
  Complex :: Int -&gt; Int -&gt; Complex
  </code></pre>
  
  <p>How can I change this to accept any Num type, instead of just Int.</p>
  
  <p>I tried following:</p>
  
  <pre><code>Prelude&gt; data Complex a = Num a =&gt; Complex a a
  </code></pre>
  
  <p>but got this:</p>
  
  <pre><code>* Data constructor `Complex' has existential type variables, a context, or a specialised result type
      Complex :: forall a. Num a =&gt; a -&gt; a -&gt; Complex a
      (Use ExistentialQuantification or GADTs to allow this)
  * In the definition of data constructor `Complex'
    In the data type declaration for `Complex'
  </code></pre>
  
  <p>I'm not really sure what to make of this error. Any help is appreciated.</p>