summaryrefslogtreecommitdiffhomepage
path: root/Types.hs
blob: 33df35c3a7ef8bad726fb49e66fac5560d7b9d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module Types where

import Data.ByteString
import qualified Crypto.Hash as H

-- | Things that the developer sees.
data Seen = Seen
	{ seenData :: ByteString
	}
	deriving (Show)

-- | Things that the developer enters.
data Entered = Entered
	{ enteredData :: ByteString
	, echoData :: ByteString
	-- ^ Data that is expected to be Seen, but has not been received
	-- at the time this was entered.
	}
	deriving (Show)

-- | An activity (either Entered or Seen) with a pointer
-- to the Activity before this one.
--
-- The Signature is over both the data in the activity, and its pointer.
data Activity a
	= Activity a HashPointer Signature
	| StartActivity a Signature
	deriving (Show)

activityContent :: Activity a -> a
activityContent (Activity a _ _) = a
activityContent (StartActivity a _) = a

data Signature = Signature ByteString
	deriving (Show)

-- | A SHA2 hash pointer to something that hashes to this value.
newtype HashPointer = HashPointer (H.Digest H.SHA256)
	deriving (Show, Eq)