<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Hello - I think the pattern for the empty list (as second argument)<span id="ms-outlook-android-cursor"></span> is missing.</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Beginners <beginners-bounces@haskell.org> on behalf of Galaxy Being <borgauf@gmail.com><br>
<b>Sent:</b> Sunday, December 12, 2021 6:14:03 AM<br>
<b>To:</b> The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org><br>
<b>Subject:</b> [Haskell-beginners] Non-exhaustive patterns</font>
<div> </div>
</div>
<div>
<div dir="ltr">This code
<div><br>
</div>
<div><font face="monospace">myTakePM :: Int -> [a] -> [a]<br>
myTakePM 0 _ = []<br>
myTakePM n (x:xs) = x : myTakePM (n-1) xs</font><br>
</div>
<div><br>
</div>
<div>is bad because it allows </div>
<div><br>
</div>
<div><font face="monospace">myTakePM 4 [1,2,3]<br>
</font></div>
<div><font face="monospace"> [1,2,3*** Exception: <interactive>:(395,1)-(396,41): Non-exhaustive patterns in function myTakePM</font><br>
</div>
<div><br>
</div>
<div>I knew it would not work, but why is it calling this essentially a partial function? How does it know this? Again, I expected an error, but what is this
<font face="monospace">Non-exhaustive patterns in function myTakePM</font> saying? Or, said another way, what exactly is non-exhaustive about this?</div>
<div>
<div>--<br>
</div>
<div dir="ltr" class="x_gmail_signature">
<div dir="ltr">
<div>⨽<br>
</div>
Lawrence Bottorff
<div>Grand Marais, MN, USA</div>
<div><a href="mailto:borgauf@gmail.com" target="_blank">borgauf@gmail.com</a></div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>