<p><br>
On Jan 20, 2012 8:31 AM, &quot;John Meacham&quot; &lt;<a href="mailto:john@repetae.net">john@repetae.net</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; As expected, no warnings. But if I change this &quot;unfailable&quot; code above<br>
&gt; &gt; to the following failable version:<br>
&gt; &gt;<br>
&gt; &gt;    data MyType = Foo | Bar<br>
&gt; &gt;<br>
&gt; &gt;    test myType = do<br>
&gt; &gt;        Foo &lt;- myType<br>
&gt; &gt;        return ()<br>
&gt; &gt;<br>
&gt; &gt; I *still* get no warnings! We didn&#39;t make sure the compiler spits out<br>
&gt; &gt; warnings. Instead, we guaranteed that it *never* will.<br>
&gt;<br>
&gt; This is actually the right useful behavior. using things like<br>
&gt;<br>
&gt; do<br>
&gt;   Just x &lt;- xs<br>
&gt;   Just y &lt;- ys<br>
&gt;   return (x,y)<br>
&gt;<br>
&gt; will do the right thing, failing if xs or ysresults in Nothing. for<br>
&gt; instance, in the list monad, it will create the cross product of the<br>
&gt; non Nothing members of the two lists. a parse monad may backtrack and<br>
&gt; try another route, the IO monad will create a useful (and<br>
&gt; deterministic/catchable) exception pointing to the exact file and line<br>
&gt; number of the pattern match. The do notation is the only place in<br>
&gt; haskell that allows us to hook into the pattern matching mechanism of<br>
&gt; the language in a general way.<br>
&gt;<br>
&gt;    John</p>
<p>I mention later that this is a &quot;feature, not a bug&quot; to some people, but I&#39;m not one of them. The convenience of having this feature is IMO far outweighed by the cost of the runtime errors it can produce if you use the pattern matching in the wrong monad (e.g., IO, Reader, Writer...).</p>

<p>Michael</p>