<div dir="ltr">Hi Tom,<div><br></div><div>The code can be found here: <a href="https://github.com/AmpersandTarski/Ampersand/blob/upgrade-ghc/src/Ampersand/Core/ParseTree.hs">https://github.com/AmpersandTarski/Ampersand/blob/upgrade-ghc/src/Ampersand/Core/ParseTree.hs</a></div><div><br></div><div>The idea is that I have several data definitions each with a field named `pos`. I have a class that conveniently gets that field from whatever instance. This used to work, but now is broken:</div><div><br></div><div>data Foo = Foo</div><div> { pos :: !Origin,</div><div> ... other fields</div><div> }</div><div>data Bar = Bar</div><div> { pos :: !Origin,</div><div> ... other fields</div><div> }</div><br>class Traced a where<br> origin :: a -> Origin<br> <div>instance Traced Foo where<br> origin = pos<br></div><div><br></div><div><div>instance Traced
Bar where<br> origin = pos<br></div><div><br></div></div><div>Of course I could rewrite the instance definitions something like</div><div><br></div><div>instance Traced Foo where</div><div> origin (Foo{pos = p} = p</div><div><br></div><div>but that looks ugly, and it feels strange. </div><div><br></div><div>Thanks for replying </div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Op di 9 apr 2024 om 12:38 schreef Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2023@jaguarpaw.co.uk">tom-lists-haskell-cafe-2023@jaguarpaw.co.uk</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Han,<br>
<br>
Would it be possible to produce a minimal example that demonstrates<br>
the problem? Or at the very least share the code? It's very hard to<br>
know where to start diagnosing. (Although perhaps someone else knows<br>
without having to see code.)<br>
<br>
At a wild guess, have you been hit by this?<br>
<br>
> As of GHC 9.4.1, selector names have to be entirely unambiguous<br>
> (under the usual name resolution rules), while for record updates,<br>
> there must be at most one datatype that has all the field names<br>
> being updated.<br>
<br>
<a href="https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/duplicate_record_fields.html#extension-DuplicateRecordFields" rel="noreferrer" target="_blank">https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/duplicate_record_fields.html#extension-DuplicateRecordFields</a><br>
<br>
Tom<br>
<br>
<br>
<br>
On Tue, Apr 09, 2024 at 12:18:14PM +0200, Han Joosten wrote:<br>
> Hi all,<br>
> <br>
> I am currently migrating a Haskell project that uses ghc 8.10.7 to ghc<br>
> 9.6.4.<br>
> <br>
> Using the new version, I get errors like<br>
> <br>
> ~~~.haskell<br>
> Ambiguous occurrence ‘pos’<br>
> It could refer to<br>
> either the field ‘pos’ of record ‘PClassify’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:1265:5<br>
> or the field ‘pos’ of record ‘PPurpose’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:1186:5<br>
> or the field ‘pos’ of record ‘P_ViewSegment’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:1129:5<br>
> or the field ‘pos’ of record ‘P_ViewD’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:1080:5<br>
> or the field ‘pos’ of record ‘P_IdentDf’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:1024:5<br>
> or the field ‘pos’ of record ‘P_BoxItem’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:981:9<br>
> or the field ‘pos’ of record ‘TemplateKeyValue’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:959:5<br>
> or the field ‘pos’ of record ‘BoxHeader’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:947:5<br>
> or the field ‘pos’ of record ‘P_SubIfc’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:934:9<br>
> or the field ‘pos’ of record ‘P_Interface’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:899:5<br>
> or the field ‘pos’ of record ‘P_Population’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:870:9<br>
> or the field ‘pos’ of record ‘P_Rule’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:806:5<br>
> or the field ‘pos’ of record ‘PairViewSegment’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:740:9<br>
> or the field ‘pos’ of record ‘P_NamedRel’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:591:5<br>
> or the field ‘pos’ of record ‘PAtomPair’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:467:5<br>
> or the field ‘pos’ of record ‘Pragma’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:415:5<br>
> or the field ‘pos’ of record ‘P_Relation’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:408:5<br>
> or the field ‘pos’ of record ‘Representation’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:339:5<br>
> or the field ‘pos’ of record ‘PConceptDef’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:268:5<br>
> or the field ‘pos’ of record ‘P_Pattern’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:209:5<br>
> or the field ‘pos’ of record ‘Role’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:185:5<br>
> or the field ‘pos’ of record ‘P_RoleRule’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:172:5<br>
> or the field ‘pos’ of record ‘P_Enforce’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:152:5<br>
> or the field ‘pos’ of record ‘MetaData’,<br>
> defined at<br>
> /workspaces/AmpersandNamespace/src/Ampersand/Core/ParseTree.hs:136:5<br>
> <br>
> Previously, it was totally fine to have different data types each have a<br>
> field with the same name, as long as you used `DuplicateRecordFields`<br>
> <br>
> I have searched the migration documentation but I couldn't find any clue on<br>
> why this has been changed or how to deal with it. I probably missed it.<br>
> Any help is mostly appreciated!<br>
> <br>
> Thanks for reading<br>
> Cheers,<br>
> Han Joosten<br>
<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.<br>
<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>