title: Haskell N-ary tree construction
body: <p>I am new in Haskell. I trying to learn implementation of N-ary trees in Haskell. I tried to construct N-ary tree and so I create my own data type</p>
  
  <pre><code>      data Tree = Empty | Node Integer [Tree] deriving Show
  </code></pre>
  
  <p>I want to construct my Tree from the list. I want to construct such Tree that going to take List elements one by one . If element is smaller it is going to be subtree of previous element else it going to be sibling.My problem is in the base cases and recursion parts. So I write such a code:</p>
  
  <pre><code>      arrin :: [Integer] -&gt; Integer -&gt; Integer {-this function takes an array -}
        arrin (x:xs) i                           {- and indexs and return the element-}  
          | i == 0    = x                    {-of that array which on that index -}
          | otherwise = arrin xs (i-1)  
  
  
        listToTree :: Integer -&gt; [Integer] -&gt; Tree
        listToTree _ [] = Empty {-First Input will be zero initially-}
        listToTree 11 _ = Empty {-Lets assume that the lenght of my list is 10-}
        listToTree 0 a = Node ( arrin a 0 ) [listToTree 1 a]
        listToTree num a  {-I need your help in this part what should i do-}
            | arrin a num &gt; arrin a (num+1) = Node ( arrin a num ) [listToTree (num+1) a]
            | otherwise = Node ( arrin a num ) [Empty]
  </code></pre>
  
  <p>Any kind of comments and answers will be appreciated.</p>