summaryrefslogtreecommitdiffhomepage
path: root/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Types.hs')
-rw-r--r--Types.hs21
1 files changed, 13 insertions, 8 deletions
diff --git a/Types.hs b/Types.hs
index a439c7c..7837f71 100644
--- a/Types.hs
+++ b/Types.hs
@@ -1,5 +1,11 @@
{-# LANGUAGE DeriveGeneric, FlexibleInstances #-}
+{- | Main types for debug-me
+ -
+ - Note that changing types in ways that change the JSON serialization
+ - changes debug-me's wire format.
+ -}
+
module Types (
module Types,
Val(..)
@@ -37,7 +43,7 @@ instance FromJSON Entered
-- The Signature is over both the data in the activity, and its pointer.
data Activity a = Activity
{ activity :: a
- , prevActivity :: (Maybe HashPointer)
+ , prevActivity :: (Maybe Hash)
, signature :: Signature
}
deriving (Show, Generic)
@@ -50,11 +56,11 @@ instance FromJSON (Activity Entered)
-- | A log of Activity both Entered and Seen.
data ActivityLog
= ActivitySeen
- { activitySeen :: Activity Seen
+ { activitySeen :: (Activity Seen, Hash)
}
| ActivityEntered
- { activityEntered :: Activity Entered
- , activityEnteredAccepted :: Bool
+ { activityEnteredAccepted :: Bool
+ , activityEntered :: (Activity Entered, Hash)
}
deriving (Show, Generic)
@@ -67,15 +73,14 @@ newtype Signature = Signature Val
instance ToJSON Signature
instance FromJSON Signature
--- | A hash pointer to something that hashes to this value.
-data HashPointer = HashPointer
+data Hash = Hash
{ hashMethod :: HashMethod
, hashValue :: Val
}
deriving (Show, Generic, Eq)
-instance ToJSON HashPointer
-instance FromJSON HashPointer
+instance ToJSON Hash
+instance FromJSON Hash
-- | We use SHA256. (SHA3 is included to future proof, and because it
-- improves the generated JSON.)