<div dir="ltr">Thanks, you and Roman are right.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Apr 13, 2014 at 2:48 PM, Oliver Charles <span dir="ltr"><<a href="mailto:ollie@ocharles.org.uk" target="_blank">ollie@ocharles.org.uk</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5">On Sun, Apr 13, 2014 at 12:24 PM, Roman Cheplyaka <<a href="mailto:roma@ro-che.info" target="_blank">roma@ro-che.info</a>> wrote:<br>

> * Konstantine Rybnikov <<a href="mailto:k-bx@k-bx.com" target="_blank">k-bx@k-bx.com</a>> [2014-04-13 12:21:44+0200]<br>
>> Just FYI, this still gives a warning:<br>>> ...<br>>>     case m of<br>>>       [] -> putStrLn "empty"<br>>>       (M.toList -> (x:_)) -> putStrLn $ "ok, some random elem is: " ++ show x<br>


><br>> Does that surprise you? The compiler doesn't have any special knowledge about<br>> the M.toList function to infer that these two cases are exhaustive.<br><br></div></div>Roman is right, and I think it's clearer if you consider this without view patterns:<br>


<br><font face="courier new, monospace">case m of<br>  [] -> ...<br>  m' -> case M.toList m' of<br>           (x : _) -> ...<br></font><br>Looking at this, it's clear that the patterns are not exhaustive - you didn't match the scenario that M.toList m' produced an empty list.<div>


<br></div><div><i>You</i> know that M.toList (M.fromList []) == [], but GHC doesn't - and I think this is where the problem lies. With that information you might be able to have exhaustive pattern matches there.</div>


<div><br></div><div>- ocharles</div></div>
</blockquote></div><br></div>