<p dir="ltr">What about using new type and sort the pair before comparing?</p>
<div class="gmail_quote">Dne 26.6.2015 15:56 "Matt Williams" <<a href="mailto:matt.williams45.mw@gmail.com">matt.williams45.mw@gmail.com</a>> napsal(a):<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Dear All,<br><br></div>I am trying to produce a Map, where the (tricky) idea is that the key is a pair, (t1, t2), and the key is considered identical under ordering. Thus:<br><br></div>(t1, t2) is the same as (t2, t1) but<br></div>(t1, t3) is not the same as (t1,t2).<br><br></div>This LOOKS like a equality definition. However, the Map key typeclass is defined as Ord, which requires me to define compare:<br><pre><code><span>instance</span><span> Ord Edge </span><span>where</span><span>
  </span><span>(</span><span>Edge s1 </span><span>_</span><span>)</span><span> </span><span>`</span><span>compare</span><span>`</span><span> </span><span>(</span><span>Edge s2 </span><span>_</span><span>)</span><span> </span><span>=</span><span> s1 </span><span>`</span><span>compare</span><span>`</span><span> s2<br><span style="font-family:arial,helvetica,sans-serif"><br></span></span></code></pre><pre><span style="font-family:arial,helvetica,sans-serif"><code><span>I am a bit stuck on how to use compare to define this type of eqlaity - any pointers very gratefully received.<br></span></code></span></pre><pre><span style="font-family:arial,helvetica,sans-serif"><code><span>BW,<br></span></code></span></pre><pre><span style="font-family:arial,helvetica,sans-serif"><code><span>Matt<br></span></code></span></pre><br></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div>