<div dir="ltr"><div><div><br>The closest thing to guards that'll work is multi-way-if (you'll have to put "{-# LANGUAGE MultiWayIf #-}" at the top of your source file)<br><br></div>e.g.<br><br>buysell = if | oldbuysell ot == "buy"  = Buy<br>

                  | oldbuysell ot == "sell" = Sell<br>
                  | otherwise               = Unknown<br><br></div>but a 'case' is slightly shorter here:<br><br><br>buysell = case oldbuysell ot of<br>   "buy"  -> Buy<br>
   "sell" -> Sell<br>
   _ -> Unknown<br><div class="gmail_extra"><br><br></div><div class="gmail_extra">Tom<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 14, 2014 at 4:22 AM, Kim-Ee Yeoh <span dir="ltr"><<a href="mailto:ky3@atamo.com" target="_blank">ky3@atamo.com</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 class=""><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 14, 2014 at 1:03 PM, Dimitri DeFigueiredo <span dir="ltr"><<a href="mailto:defigueiredo@ucdavis.edu" target="_blank">defigueiredo@ucdavis.edu</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    oldbuysell :: String  -- "buy", "sell" or ""</blockquote></div><br></div></div><div class="gmail_extra">Why is this String when you've defined the perfectly cromulent BuyOrSell datatype?<br>


<br></div><div class="gmail_extra">How can you be sure there won't be some accidental buggy code that sets the field to "buyy"?<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra">
<br clear="all"><div>-- Kim-Ee</div>
</div></font></span></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div></div>