module LMonad.Label.PowerSet where
import Data.Set (Set)
import qualified Data.Set as Set
import Prelude
import LMonad
data Ord p => PSLabel p = PSLabel {
psLabelConfidentiality :: Set p
, psLabelIntegrity :: Set p
}
deriving Show
psSingleton :: Ord p => p -> PSLabel p
psSingleton p =
let p' = Set.singleton p in
PSLabel p' p'
psConfidentialitySingleton :: Ord p => p -> PSLabel p
psConfidentialitySingleton p =
let p' = Set.singleton p in
PSLabel p' Set.empty
psIntegritySingleton :: Ord p => p -> PSLabel p
psIntegritySingleton p =
let p' = Set.singleton p in
PSLabel Set.empty p'
instance Ord p => Label (PSLabel p) where
glb (PSLabel c1 i1) (PSLabel c2 i2) =
let c = Set.intersection c1 c2 in
let i = Set.intersection i1 i2 in
PSLabel c i
lub (PSLabel c1 i1) (PSLabel c2 i2) =
let c = Set.union c1 c2 in
let i = Set.union i1 i2 in
PSLabel c i
canFlowTo (PSLabel c1 i1) (PSLabel c2 i2) =
(Set.isSubsetOf c1 c2) && (Set.isSubsetOf i1 i2)
bottom =
PSLabel Set.empty Set.empty
type PSLabeled p = Labeled (PSLabel p)