title: Combine two parsec parsers with types integer and double to a new parser of type number
body: <p>so I can't get my head around this problem:</p>
  
  <p>I have the following code:</p>
  
  <pre><code>   data Number = NumberInt Integer
                  | NumberFloat Double
                  deriving(Show, Eq)
  
  
     intParser :: Parser Integer
      --code of the parser
  
     doubleParser :: Parser Double
      --code of the parser
  
     intOrFloat :: Parser Number
     intOrFloat = -- to do
  </code></pre>
  
  <p>one of my approaches was to implement the intOrFloat the following way:</p>
  
  <pre><code>intOrFloat :: Parser Number
  intOrFloat =
        (do
          e&lt;- doubleParser
          let result = (e :: Number)
          pure result)
        &lt;|&gt;
        (do
          f&lt;- intParser
          let result = (f :: Number)
          pure result
  
        )
  </code></pre>
  
  <p>But I always end up with the error:
  Couldn't match expected type ‘Number’ with actual type ‘Integer’</p>
  
  <p>Could somebody please explain me how to combine the two parsers to a new parser with another type ? I don't understand what the problem is.
  I am using parsec.</p>
  
  <p>I am new to Haskell so please be gentle.
  Thank you.</p>