<div class="gmail_quote">On Thu, May 3, 2012 at 5:36 PM, Ismael Figueroa Palet <span dir="ltr"><<a href="mailto:ifigueroap@gmail.com" target="_blank">ifigueroap@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, I'm writing a program like this:<div><br></div><div>data B = B Int</div><div>data A = Safe Int | Unsafe Int</div><div><br></div><div>createB :: A -> B</div><div>createB (Safe i) = B i</div><div>createB (Unsafe i) = error "This is not allowed"</div>
<div><br></div><div>Unfortunately, the situation when createB is called with an Unsafe value is only checked at runtime. </div><div>If I omit the second case, it is not an error to not be exhaustive :-(</div></blockquote>
<div><br></div><div>It is a warning at least, if you use the appropriate -W flag, or -Wall. You can combine it with -Werror to make it a compile-time error to omit cases in a pattern match (and other warnings.)</div><div>
<br></div><div>I'm not quite sure what your intention with the A data type is. createB could also have the signature A -> Maybe B, so the caller might check the outcome instead of having the entire program crash.</div>
<div><br></div><div>Cheers,</div><div>Aleks</div></div>