[Haskell-cafe] Domain modeling

Erik Hesselink hesselink at gmail.com
Wed Jan 29 14:41:47 UTC 2020


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.

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.

Cheers,

Erik

On Wed, 29 Jan 2020 at 15:13, Jean Lopes <hawu.bnu at gmail.com> wrote:

> Hi!
>
> I'm trying to encode a domain which is full of simple records, and a lot
> of field name clashes.
>
> Here is a simple example, a.k.a. 1:1 with the domain-spec:
>
> data C001 {
>>   -- other stuff
>>   indMov :: Bool
>> }
>> data C170 {
>>   -- other stuff
>>  indMov :: Bool
>> }
>
>
> There is ~148 records with this field (indMov), all with the same meaning.
> What are my options to encode this in Haskell?
>
> - Prefix all record fields to avoid name clashes?
> - Use *DuplicateRecordFields*?
> - Typeclasses???
> - other options I am not aware of?
>
> which would you prefer? and why of course :)
>
> Thanks,
> Jean Lopes
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200129/e1352506/attachment.html>


More information about the Haskell-Cafe mailing list