title: Creating a data type list Haskell
body: <p>I've done a personal list in Haskell like this:  (2,(1,1),3) -> List [Num 2, List [Num 1, Num 1], List [Num 3]].</p>
  
  <p>This is how I made it:</p>
  
  <pre><code>data SList a = Num a | List [SList a] deriving Show
  emptySList :: SList a
  emptySList = (List [])
  
  consElem :: a -&gt; SList a -&gt; SList a
  consElem x (List y) = (List ((Num x) : y))
  
  consList :: SList a -&gt; SList a -&gt; SList a
  consList a b = (List [a,b])
  </code></pre>
  
  <p>I manage to form this list (List [Num 2, List [Num 1, Num 1], List [Num 3]]) using consElem and consList like this: </p>
  
  <pre><code>consElem 2 $ consList (consElem 1 $ consElem 1 emptySList) $ consElem 3 emptySList
  </code></pre>
  
  <p>I wonder how can I transform a SList in a normal list. For example if I have this SList: <code>List [Num 2, List [Num 1, Num 1], List [Num 3]]</code> it should become <code>[2,1,1,3]</code>.</p>
  
  <p>My attempt:</p>
  
  <pre><code>atomToNormal x
      | null x = []
      | otherwise = slistToList (head x) ++ atomToNormal (tail x)
  slistToList :: SList a -&gt; [a]
  slistToList (List x) = atomToNormal x
  slistToList (Num x) = [x]
  </code></pre>