<div dir="ltr">Thank you so much :) </div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 24, 2015 at 2:01 PM, Francesco Ariis <span dir="ltr"><<a href="mailto:fa-ml@ariis.it" target="_blank">fa-ml@ariis.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Nov 24, 2015 at 01:20:03PM -0500, Jeon-Young Kang wrote:<br>
> Dear All.<br>
><br>
> I'd like to compare fields of each record.<br>
><br>
> here is my record.<br>
><br>
> data Person = Person {name:: String, age:: Int } deriving(Show)<br>
> data Relations = Friend | Older | Younger<br>
><br>
> class Comparison a where<br>
> compare:: a -> a -> Relations<br>
><br>
> instance Comparison Person where<br>
> compare Person a b Person a b<br>
> | b1 == b2 = Friend<br>
> | b1 > b2 = Older<br>
> | b1 < b2 = Younger<br>
><br>
> How can I fit it?<br>
><br>
> Sincerely,<br>
><br>
><br>
> Jeon-Young Kang<br>
<br>
</div></div>Hello Jeon-Young, I attach a version that compiles. Keep in mind that<br>
<br>
compare (Person x y) (Person q w) -- this is legal<br>
<br>
compare Person x y Person q w -- "space" takes precedence over everything,<br>
-- so this function has 6 arguments<br>
-- instead of the expected 2!<br>
<br>
<br>
λ> Main.compare (Person "cdsac" 1) (Person "cdscasd" 20)<br>
Younger<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Department of Geography</div><div>State University of New York at Buffalo</div><div><br></div><div><a href="mailto:jykang22@gmail.com" target="_blank">jykang22@gmail.com</a></div><div> </div><div>Jeon-Young Kang</div></div></div>
</div>