<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<blockquote cite="mid:1C251FDC-4448-4593-AFBE-50024BA51AB2@qq.com"
type="cite">
<blockquote type="cite" class="">
<div text="#000000" bgcolor="#FFFFFF" class=""> Which brings us
back to fclabels I suppose.</div>
</blockquote>
<div class=""><font class="" face="Courier">Can you elaborate
this? I haven’t fully understand what is “incorporate the tag
in the class from the start” . Thanks you.</font></div>
</blockquote>
<br>
Suppose you have the original definitions<br>
<blockquote>
<div class=""><tt><font class="">class Has a t where</font></tt></div>
<div class=""><tt><font class=""> get :: t -> a</font></tt></div>
<div class=""><tt><font class=""><br class="">
</font></tt></div>
<div class=""><tt><font class="">
<div class="">instance Has a (a, b) where</div>
<div class=""> get (a, _) = a</div>
<div class=""><br class="">
</div>
<div class="">instance Has b (a, b) where</div>
<div class=""> get (_, b) = b</div>
</font></tt></div>
</blockquote>
This creates a conflict if you use an <tt>(Int,Int)</tt> tuple
because there are either no definitions or two conflicting
definitions for <tt>get</tt>.<br>
As a solution you propose something along the lines of<tt><font
class=""><br>
</font></tt>
<blockquote><tt><font class="">Has (Tagged “GetGetsFirst” a) (a,b)</font></tt><br>
</blockquote>
<font class=""> All I'm saying is that it seems useful or even
necessary for sanity to combine </font><font class=""><tt>Has</tt></font><font
class=""> and </font><font class=""><tt>Tagged</tt></font><font
class=""> so that you can write</font><font class=""> </font><br>
<blockquote><tt><font class="">Has “fst” a (a,b)</font></tt><br>
</blockquote>
<font class="">The implementation should be something simple like</font><br>
<blockquote>
<div class=""><tt><font class="">class (KnownSymbol label) =>
Has label part whole | whole,label -> part where</font></tt></div>
<tt><font class=""> get :: Proxy label -> whole -> part<br>
-- 'Proxy label' is necessary because 'whole' and 'part' alone
are not sufficient to determine the label. See (Int,Int).</font></tt><br>
</blockquote>
<div class=""><font class="">The obvious downside is that it doesn't
make as much sense to have such a class now. I must admit I'm
not too familiar with the alternatives, so I can't really
compare it. But this was just a flaw I saw. Hope this cleared up
what I meant.<br>
<br>
Cheers,<br>
MarLinn<br>
</font><tt><font class=""></font></tt></div>
<br>
<blockquote cite="mid:1C251FDC-4448-4593-AFBE-50024BA51AB2@qq.com"
type="cite">
<div>
<blockquote type="cite">
<div>
<div>
<blockquote
cite="mid:F4FCDA9B-028C-4A4D-9369-D81C9257595F@qq.com"
type="cite">
<div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">Does this differ
significantly from fclabels or the upcoming
OverloadedRecordFields extension? (Aside from
being purely type driven, which has problems in
your example if you compose a second Int into
it.) </div>
</div>
</blockquote>
</div>
<div><font class="" face="Courier">1. Yes, it’s similar
to OverloadedRecordFields but doesn’t force you to
use a label, and you may use Tagged to label a field
if you want.</font></div>
<div class=""><font face="Courier">2. Yes, but again,
you can use Tagged to allow same type in different
disguise.</font></div>
</blockquote>
I can see a potential problem because you can't hide
instances. Once you define a Has-relationship, you can't
cheaply change it. That could lead to conflicts, unless
you hack around it with orphaned instances in a separate
module. But you say you want to solve conflicts with
tagging – so it would be reasonable to incorporate the tag
in the class from the start. Which brings us back to
fclabels I suppose. </div>
</div>
</blockquote>
</div>
</blockquote>
</body>
</html>