From 74003096f8018827dde28b5746a19c1e325bc68f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 14 Apr 2017 19:39:23 -0400 Subject: add --graphviz mode This commit was sponsored by Shane-o on Patreon. --- Types.hs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'Types.hs') 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.) -- cgit v1.2.3