title: Data constructor not in scope
body: <p>I'm learning Haskell and writing a simple program. Now I'm getting a problem, which for me, is quite confusing. Here is the code:</p>
  
  <pre><code>data VariableName = X|Y deriving Show  
  getValue :: VariableName -&gt; Int
  getValue X = 5
  getValue Y = 13
  
  data Expression = Constant|Variable|Add|Multiply deriving Show
  evaluate :: Expression -&gt; Int
  evaluate Constant x = x
  evaluate Variable x = getValue x
  evaluate Add x y = x+y
  evaluate Multiply x y = x * y
  </code></pre>
  
  <p>I expect the output:</p>
  
  <pre><code>Constant  20  = 20
  </code></pre>
  
  <p>but I'm getting</p>
  
  <pre><code>*Main&gt; evaluate Constant 20
  
  &lt;interactive&gt;:79:1: error:
      Variable not in scope: evaluate :: t0 -&gt; Integer -&gt; t
  
  &lt;interactive&gt;:79:10: error: Data constructor not in scope: Constant
  </code></pre>
  
  <p>But when e.g.:  I write </p>
  
  <pre><code>*Main&gt; getValue X
  5
  </code></pre>
  
  <p>Which is the right answer. I just started Haskell, which is way this is quite confusing for me. Some help would be much appreciated.</p>