{-# LANGUAGE CPP #-} #if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 704) {-# LANGUAGE Trustworthy #-} #endif {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {- | This module provides instances for binary serialization of 'DCLabel's. Specifically, we provide insgtances for @cereal@\'s @Data.Serialize@. -} module DCLabel.Serialize () where import DCLabel.Core import Data.Serialize import Control.Monad deriving instance Serialize Principal deriving instance Serialize Clause -- | Serialize components by converting them to maybe's instance Serialize Component where put c = put . dcToMaybe $! c where dcToMaybe DCFalse = Nothing dcToMaybe (DCFormula f) = Just f get = dcFromMaybe `liftM` get where dcFromMaybe Nothing = dcFalse dcFromMaybe (Just f) = dcFormula f -- | Serialize labels by converting them to pairs of components. instance Serialize DCLabel where put l = put (dcSecrecy l, dcIntegrity l) get = uncurry dcLabelNoReduce `liftM` get