title: Haskell : Possible cause: ‘(:)’ is applied to too many arguments
body: <p>I‘ve created a nested function which fails at the third nesting. I fail to understand why this pattern holds up for the previous two nests but not the third. I'm attempting to recursively work through the list to add the items in the list together</p>
  
  <pre><code>module Nests 
  (nest1,nest2,nest3) where
  
  nest1 :: (Num a) =&gt; [a] -&gt; [a] -&gt; [a]
  nest1 _ [] = []
  nest1 [] _ = []
  nest1 (xs:ls1) (xt:ls2) = (xs+xt):nest1 ls1 ls2
  
  nest2 :: (Num a) =&gt; [[a]] -&gt; [[a]] -&gt; [[a]]
  nest2 _ [] = []
  nest2 [] _ = []
  nest2 (xs:ls1) (xt:ls2) = (nest1 xs xt):nest2 ls1 ls2
  
  nest3 :: (Num a) =&gt; [[[a]]] -&gt; [[[a]]] -&gt; [[[a]]]
  nest3 (xs:xt:ls)
      | length ls &lt;= 0 = []
      | otherwise = (nest2 xs xt):nest3 ls
  </code></pre>
  
  <p>where compiled:</p>
  
  <pre><code>nests.hs:17:19: error:
      • Couldn't match expected type ‘[[[a]]] -&gt; [[[a]]]’
                    with actual type ‘[[[a]]]’
      • Possible cause: ‘(:)’ is applied to too many arguments
        In the expression: (nest2 xs xt) : nest3 ls
        In an equation for ‘nest3’:
            nest3 (xs : xt : ls)
              | length ls &lt;= 0 = []
              | otherwise = (nest2 xs xt) : nest3 ls
      • Relevant bindings include
          ls :: [[[a]]] (bound at nests.hs:15:14)
          xt :: [[a]] (bound at nests.hs:15:11)
          xs :: [[a]] (bound at nests.hs:15:8)
          nest3 :: [[[a]]] -&gt; [[[a]]] -&gt; [[[a]]] (bound at nests.hs:15:1)
     |
  17 |     | otherwise = (nest2 xs xt):nest3 ls
     |                   ^^^^^^^^^^^^^^^^^^^^^^
  
  nests.hs:17:33: error:
      • Couldn't match expected type ‘[[[a]]]’
                    with actual type ‘[[[a]]] -&gt; [[[a]]]’
      • Probable cause: ‘nest3’ is applied to too few arguments
        In the second argument of ‘(:)’, namely ‘nest3 ls’
        In the expression: (nest2 xs xt) : nest3 ls
        In an equation for ‘nest3’:
            nest3 (xs : xt : ls)
              | length ls &lt;= 0 = []
              | otherwise = (nest2 xs xt) : nest3 ls
      • Relevant bindings include
          ls :: [[[a]]] (bound at nests.hs:15:14)
          xt :: [[a]] (bound at nests.hs:15:11)
          xs :: [[a]] (bound at nests.hs:15:8)
          nest3 :: [[[a]]] -&gt; [[[a]]] -&gt; [[[a]]] (bound at nests.hs:15:1)
     |
  17 |     | otherwise = (nest2 xs xt):nest3 ls
  </code></pre>