cqrs-0.2.0: src/Data/CQRS/Aggregate.hs
-- | Aggregate type class.
module Data.CQRS.Aggregate
( Aggregate(..)
) where
import Data.ByteString (ByteString)
-- | Type class for aggregates.
class Aggregate a where
-- | Encode aggregate into a ByteString representation. The
-- representation should contain some metadata (a UUID for example)
-- which can be used to check reliably whether the encoded
-- representation is valid upon decoding. This can be used if the
-- actual aggregate structure changes.
encodeAggregate :: a -> ByteString
-- | Decode ByteString to aggregate state. If decoding is not
-- possible should return 'Nothing'.
decodeAggregate :: ByteString -> Maybe a