<div dir="ltr"><div>This is a good opportunity to use case syntax. You can also case on tuples, like this:</div><div><br></div><div>```</div><div>foo a b = case (a,b) of</div><div>  (A1,B1) -> fun1</div><div>  (A1,B2) -> fun2</div><div>  (A1,B3) -> fun3</div><div>  (A1,_)  -> fun4   <- this is probably not necessary anymore, unless you expect Rule2 to get more constructors.<br></div><div>  (A2,B1) -> fun5</div><div>  ...<br></div><div>```<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 16, 2019 at 10:14 PM Magicloud Magiclouds <<a href="mailto:magicloud.magiclouds@gmail.com">magicloud.magiclouds@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
I have trouble describing this clearly. Let me show code directly.<br>
<br>
data Rule1 = A1 | A2 | A3<br>
data Rule2 = B1 | B2 | B3<br>
<br>
foo a b =<br>
  if a == A1<br>
    then if b == B1<br>
      then fun1<br>
      else if b == B2<br>
        then fun2<br>
        else if b == B3<br>
          then fun3<br>
          else fun4<br>
...<br>
<br>
Basically, Rule1 and Rule2 compose a matrix, for each case of Rule1<br>
and Rule2, I need to do different things. Above is already long and<br>
not quite clear, and it is far from complete.<br>
<br>
So my question is, is there a way/lib that I can make this clear to<br>
read/understand?<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Nathan Bloomfield<br></div>Code Wrangler, Team Absinthe<br></div><div>Automattic, Inc.<br></div></div></div></div>