diff options
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) |