[Haskell-cafe] Domain modeling

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu Jan 30 09:56:21 UTC 2020


Jean Lopes <hawu.bnu at gmail.com> writes:

> 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?

Is there some reason why they must be different types?

data C = C001 {other_stuff:: Real, indMov:: Bool } |
         C170 {other_stuff…, indMov:: Bool }

is the first thing that comes to mind.
-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list