summaryrefslogtreecommitdiffhomepage
path: root/Types.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-14 19:39:23 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-14 19:39:23 -0400
commit74003096f8018827dde28b5746a19c1e325bc68f (patch)
treede5343b6dae38d4ae06b8ad004f45b9669b28cb6 /Types.hs
parent0222ca35ec03836ab216aff1a38e337e2be16511 (diff)
downloaddebug-me-74003096f8018827dde28b5746a19c1e325bc68f.tar.gz
add --graphviz mode
This commit was sponsored by Shane-o on Patreon.
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.)