diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-18 13:04:16 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-18 13:05:02 -0400 |
commit | 1d18dcbe796820b30e0c8c1db241da95ee7566cb (patch) | |
tree | 4fdb379854ca7027744a3dca5620f7143c913575 /Types.hs | |
parent | b936e6f9df8364701eefd59720c9d85afea5e7e1 (diff) | |
download | debug-me-1d18dcbe796820b30e0c8c1db241da95ee7566cb.tar.gz |
improve types
Including adding a timestamp to logs
Diffstat (limited to 'Types.hs')
-rw-r--r-- | Types.hs | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -15,6 +15,7 @@ import Val import GHC.Generics (Generic) import Data.Aeson +import Data.Time.Clock.POSIX -- | Things that the developer sees. data Seen = Seen @@ -66,24 +67,31 @@ instance FromJSON (Activity Seen) instance ToJSON (Activity Entered) instance FromJSON (Activity Entered) +data SomeActivity + = ActivitySeen (Activity Seen) + | ActivityEntered (Activity Entered) + deriving (Show, Generic) + +instance ToJSON (SomeActivity) +instance FromJSON (SomeActivity) + -- | A log of Activity both Entered and Seen, which can be recorded to -- prove what happened in a debug-me session. -data ActivityLog - = ActivitySeen - { activitySeen :: (Activity Seen, Hash) - } - | ActivityEntered - { activityEntered :: (Activity Entered, Hash) - } +-- +-- Note that the time stamp is included to allow replaying logs, but +-- it's not part of the provable session. +data ActivityLog = ActivityLog + { loggedActivity :: SomeActivity + , loggedHash :: Hash + , loggedTimestamp :: Timestamp + } deriving (Show, Generic) -activityLogHash :: ActivityLog -> Hash -activityLogHash (ActivitySeen (_, h)) = h -activityLogHash (ActivityEntered (_, h)) = h - instance ToJSON (ActivityLog) instance FromJSON (ActivityLog) +type Timestamp = POSIXTime + newtype Signature = Signature Val deriving (Show, Generic) |