summaryrefslogtreecommitdiff
path: root/src/Identity.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-05-17 22:06:01 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-05-17 22:06:01 +0200
commitb8e55c64a68763b0953945476cc75206f5354023 (patch)
tree741f7e66faace0be22ecaa6346f2ca79c045893b /src/Identity.hs
parentb9e50633254a8c45159a6088309969872b8aae50 (diff)
Mergeable class with separate component type
Diffstat (limited to 'src/Identity.hs')
-rw-r--r--src/Identity.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Identity.hs b/src/Identity.hs
index b81228f..834e5ee 100644
--- a/src/Identity.hs
+++ b/src/Identity.hs
@@ -52,8 +52,8 @@ deriving instance Show (m (Stored (Signed IdentityData))) => Show (Identity m)
type ComposedIdentity = Identity []
type UnifiedIdentity = Identity I.Identity
-instance Eq UnifiedIdentity where
- (==) = (==) `on` (idData &&& idUpdates)
+instance Eq (m (Stored (Signed IdentityData))) => Eq (Identity m) where
+ (==) = (==) `on` (idData_ &&& idUpdates_)
data IdentityData = IdentityData
{ iddPrev :: [Stored (Signed IdentityData)]
@@ -79,6 +79,11 @@ instance Storable IdentityData where
<*> loadRef "key-id"
<*> loadMbRef "key-msg"
+instance Mergeable (Maybe ComposedIdentity) where
+ type Component (Maybe ComposedIdentity) = Signed IdentityData
+ mergeSorted = validateIdentityF
+ toComponents = maybe [] idDataF
+
idData :: UnifiedIdentity -> Stored (Signed IdentityData)
idData = I.runIdentity . idDataF