<div dir="ltr">
<p class="inbox-inbox-p1">The below produces an error. And I am very proud that I could use the GHCi debugging tools to get this far.</p><p class="inbox-inbox-p1"><font face="monospace">merge [] []</font> works.</p><p class="inbox-inbox-p1"><font face="monospace">merge [1] [] </font>works.</p><p class="inbox-inbox-p1">I don't know why the failing example fails. It should return:</p><p class="inbox-inbox-p1"><font face="monospace">[4,5]</font></p><p class="inbox-inbox-p1">Help to unstuck is appreciated.</p><p class="inbox-inbox-p1"><span class="inbox-inbox-s1"><font face="monospace">:step merge [4,5] []</font></span></p>
<p class="inbox-inbox-p1"><span class="inbox-inbox-s1"><font face="monospace">*** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in function merge</font></span></p><p class="inbox-inbox-p1">Given:</p><p class="inbox-inbox-p1"><font face="monospace">merge :: Ord a => [a] -> [a] -> [a]</font></p><p class="inbox-inbox-p1"><font face="monospace">merge [] [] = []</font></p><p class="inbox-inbox-p1"><font face="monospace">merge [x] [] = [x]</font></p><p class="inbox-inbox-p1"><font face="monospace">merge [] [y] = [y]</font></p><p class="inbox-inbox-p1"><font face="monospace">merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second</font></p><p class="inbox-inbox-p1"><font face="monospace"> | otherwise = y : merge first ys</font></p><div><br></div></div>