<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><font face="Courier" class="">Hi MarLinn!</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">In my use case the type collision is definitely much less likely to happen, that is i often want to compose different effects like </font><span style="font-family: Courier;" class="">logger, sql and network </span><span style="font-family: Courier;" class="">,etc. without Has class, i will have a hard time trying to compose `Reader Logger ()` and `Reader (Logger, HttpClient) ()`, since the concrete type can't be unified.</span></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">If i need two different Logger in environment, i still can do it without Tagged, i can define following newtypes in library site:</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">newtype StdLogger = </font><span style="font-family: Courier;" class="">StdLogger Logger</span></div><div class=""><font face="Courier" class="">newtype FileLogger = </font><span style="font-family: Courier;" class="">FileLogger Logger</span></div><div class=""><span style="font-family: Courier;" class=""><br class=""></span></div><div class=""><span style="font-family: Courier;" class="">librarySite :: (Has </span><span style="font-family: Courier;" class="">StdLogger r, Has </span><span style="font-family: Courier;" class="">FileLogger r, MonadReader r m</span><span style="font-family: Courier;" class="">) => m ()</span></div><div class=""><span style="font-family: Courier;" class="">librarySite = do ...</span></div><div class=""><span style="font-family: Courier;" class=""> stdLogger :: </span><span style="font-family: Courier;" class="">StdLogger</span> <span style="font-family: Courier;" class=""><- asks get</span></div><div class=""><span style="font-family: Courier;" class=""> logWith </span><span style="font-family: Courier;" class="">stdLogger</span></div><div class=""><span style="font-family: Courier;" class=""> ...</span></div><div class=""><span style="font-family: Courier;" class=""> </span><span style="font-family: Courier;" class="">f</span><span style="font-family: Courier;" class="">ileLogger</span><span style="font-family: Courier;" class=""> :: </span><span style="font-family: Courier;" class="">FileLogger</span> <span style="font-family: Courier;" class=""><- asks get</span></div><div class=""><span style="font-family: Courier;" class=""> logWith f</span><span style="font-family: Courier;" class="">ileLogger</span></div><div class=""><span style="font-family: Courier;" class=""> ...</span></div><div class=""><span style="font-family: Courier;" class=""><br class=""></span></div><div class=""><font face="Courier" class="">And in application site i should supply a (</font><span style="font-family: Courier;" class="">StdLogger log1, </span><span style="font-family: Courier;" class="">FileLogger log2, ...</span><span style="font-family: Courier;" class="">).</span></div><div class=""><span style="font-family: Courier;" class=""><br class=""></span></div><div class=""><span style="font-family: Courier;" class="">Does above example illustrate my use case to you?</span></div><div class=""><span style="font-family: Courier;" class=""><br class=""></span></div><div class=""><span style="font-family: Courier;" class="">Cheers~</span></div><div class=""><font face="Courier" class="">Winter</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div><blockquote type="cite" class=""><div class="">On 22 Nov 2016, at 21:48, MarLinn <<a href="mailto:monkleyon@googlemail.com" class="">monkleyon@googlemail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
<div text="#000000" bgcolor="#FFFFFF" class="">
<blockquote cite="mid:1C251FDC-4448-4593-AFBE-50024BA51AB2@qq.com" type="cite" class="">
<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 class="">
Suppose you have the original definitions<br class="">
<blockquote class="">
<div class=""><tt class=""><font class="">class Has a t where</font></tt></div>
<div class=""><tt class=""><font class=""> get :: t -> a</font></tt></div>
<div class=""><tt class=""><font class=""><br class="">
</font></tt></div>
<div class=""><tt class=""><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 class="">(Int,Int)</tt> tuple
because there are either no definitions or two conflicting
definitions for <tt class="">get</tt>.<br class="">
As a solution you propose something along the lines of<tt class=""><font class=""><br class="">
</font></tt>
<blockquote class=""><tt class=""><font class="">Has (Tagged “GetGetsFirst” a) (a,b)</font></tt><br class="">
</blockquote>
<font class=""> All I'm saying is that it seems useful or even
necessary for sanity to combine </font><font class=""><tt class="">Has</tt></font><font class=""> and </font><font class=""><tt class="">Tagged</tt></font><font class=""> so that you can write</font><font class=""> </font><br class="">
<blockquote class=""><tt class=""><font class="">Has “fst” a (a,b)</font></tt><br class="">
</blockquote>
<font class="">The implementation should be something simple like</font><br class="">
<blockquote class="">
<div class=""><tt class=""><font class="">class (KnownSymbol label) =>
Has label part whole | whole,label -> part where</font></tt></div>
<tt class=""><font class=""> get :: Proxy label -> whole -> part<br class="">
-- 'Proxy label' is necessary because 'whole' and 'part' alone
are not sufficient to determine the label. See (Int,Int).</font></tt><br class="">
</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 class="">
<br class="">
Cheers,<br class="">
MarLinn<br class="">
</font><tt class=""><font class=""></font></tt></div>
<br class="">
<blockquote cite="mid:1C251FDC-4448-4593-AFBE-50024BA51AB2@qq.com" type="cite" class="">
<div class="">
<blockquote type="cite" class="">
<div class="">
<div class="">
<blockquote cite="mid:F4FCDA9B-028C-4A4D-9369-D81C9257595F@qq.com" type="cite" class="">
<div class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<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 class=""><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" class="">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>
</div>
</div></blockquote></div><br class=""></body></html>