<div dir="ltr"><div>I've always been happy with the simplicity of using modules as namespaces for this. Give each data type its own module, and import qualified to avoid name clashes. If you're doing something specific to a single type, you can import unqualified and not use the prefix. The only downside is that you can't make a singe module re-exporting all the types, since you can't re-export prefixed.</div><div><br></div><div>If this field has the same meaning in each data type, and you need to write functions that are generic over all of them, go with a type class.</div><div><br></div><div>Cheers,</div><div><br></div><div>Erik<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 29 Jan 2020 at 15:13, Jean Lopes <<a href="mailto:hawu.bnu@gmail.com">hawu.bnu@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi!<br><br>I'm trying to encode a domain which is full of simple records, and a lot of field name clashes.<br><br>Here is a simple example, a.k.a. 1:1 with the domain-spec:<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">data C001 {<br></font><font face="monospace"> -- other stuff<br></font><font face="monospace"> indMov :: Bool<br></font><font face="monospace">}</font><font face="monospace"><br></font><font face="monospace">data C170 {<br></font><font face="monospace"> -- other stuff<br></font><font face="monospace"> indMov :: Bool<br></font><font face="monospace">}</font></blockquote><div><br></div><div>There is ~148 records with this field (indMov), all with the same meaning. What are my options to encode this in Haskell?</div><div><br></div><div>- Prefix all record fields to avoid name clashes?</div><div>- Use <span style="color:rgb(0,0,0);font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:16.8px"><i>DuplicateRecordFields</i></span><span style="color:rgb(0,0,0);font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:16.8px">?</span></div><div><span style="color:rgb(0,0,0);font-size:16.8px"><font face="arial, sans-serif">- Typeclasses???</font></span></div><div><span style="color:rgb(0,0,0);font-size:16.8px"><font face="arial, sans-serif">- other options I am not aware of?</font></span></div><div><br></div><div><span style="color:rgb(0,0,0);font-size:16.8px"><font face="arial, sans-serif">which would you prefer? and why of course :)</font></span></div><div><span style="color:rgb(0,0,0);font-size:16.8px"><font face="arial, sans-serif"><br></font></span></div><div><span style="color:rgb(0,0,0);font-size:16.8px"><font face="arial, sans-serif">Thanks,</font></span></div><div><span style="color:rgb(0,0,0);font-size:16.8px"><font face="arial, sans-serif">Jean Lopes</font></span></div><div><br></div><div><br></div><div> </div></div>
_______________________________________________<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>