I have the following model:
User
...
Group
...
Sharing
objectId (Either UserId GroupId)
In Sharing
entity I want to store either UserId
or GroupId
and differentiate between them. Simply using Either
doesn't work:
- Not in scope: type constructor or class `UserId'
- Not in scope: type constructor or class `GroupId'
Adding a new sum-type also doesn't work:
data SharingIdType = SharingUserId UserId | SharingGroupId GroupId
- Not in scope: type constructor or class `SharingIdType'
Moving SharingIdType
into another module isn't possible, because it uses UserId
and GroupId
types. The only way I see is to create an entity for each sharing type, like UserSharing
/GroupSharing
.
Other than that, how to approach this problem?