title: Data initialization and data members change in Haskell
body: <p>I'm new to Haskell and I cannot figure out how you declare a "Data" type and how you can initialize a variable with that type. I'd also like to know how can I change the values of certain members of that variable. For exaple :</p>
  
  <pre><code>data Memory a = A 
    { cameFrom :: Maybe Direction
    , lastVal :: val
    , visited :: [Direction]
    }
  </code></pre>
  
  <p>Direction is a Data type that contains N,S,E,W
  val is a Type int</p>
  
  <pre><code>init :: Int -&gt; a
  init n = ((Nothing) n []) gives me the following error:
  
  
  The function `Nothing' is applied to two arguments,
  but its type `Maybe a0' has none
  In the expression: ((Nothing) n [])
  In an equation for `init': init n = ((Nothing) n [])
  </code></pre>
  
  <p>how can I fix this ?</p>
  
  <p>UPDATE: That did it, thank you very much, but now i have another issue</p>
  
  <pre><code>move :: val -&gt; [Direction] -&gt; Memory -&gt; Direction
  move s cs m | s &lt; m.lastVal = m.cameFrom
              | ...
  </code></pre>
  
  <p>this gives me the following error:</p>
  
  <pre><code> Couldn't match expected type `Int' with actual type `a0 -&gt; c0'
      Expected type: val
        Actual type: a0 -&gt; c0
      In the second argument of `(&lt;)', namely `m . lastVal'
      In the expression: s &lt; m . lastVal
  </code></pre>
  
  <p>UPDATE 2: Again, that helped me a lot, thank you very much</p>
  
  <p>Also, I have another question (sorry for being such a bother)</p>
  
  <p>How do I adress only an element of a type
  For example if I have</p>
  
  <pre><code>Type Cell = (Int, Int)
  Type Direction = (Cell, Int)
  </code></pre>
  
  <p>how do I proceed if I want to compare a Cell variable with the Cell element of a Direction variable?</p>