問題タブ [haskell-persistent]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
haskell - どちらか (キー a) (キー b) を保管するにはどうすればよいですか?
私は次のモデルを持っています:
Sharing
エンティティでは、 or のいずれかを保存し、それらを区別したいと考えていUserId
ますGroupId
。単に使用Either
しても機能しません:
- 範囲外: 型コンストラクタまたはクラス `UserId'
- 範囲外: 型コンストラクタまたはクラス `GroupId'
新しい sum-type を追加しても機能しません:
- 範囲外: 型コンストラクタまたはクラス `SharingIdType'
および型SharingIdType
を使用するため、別のモジュールに移動することはできません。私が見る唯一の方法は、 /のような共有タイプごとにエンティティを作成することです。UserId
GroupId
UserSharing
GroupSharing
それ以外に、この問題にどのようにアプローチしますか?