spdx-0.2.2.0: SPDX license expression language

Copyright | (c) 2015 Oleg Grenrus
License | BSD3
Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi>
Safe Haskell | Safe
Language | Haskell98

Data.SPDX.LatticeSyntax

Description

Inspired by Simple SMT Solver.

In future this module will probably be moved into separate package.

Synopsis

- data LatticeSyntax a
  - = LVar a
  - | LBound Bool
  - | LJoin (LatticeSyntax a) (LatticeSyntax a)
  - | LMeet (LatticeSyntax a) (LatticeSyntax a)
- dual :: LatticeSyntax a -> LatticeSyntax a
- freeVars :: LatticeSyntax a -> [a]
- equivalent :: Eq a => LatticeSyntax a -> LatticeSyntax a -> Bool
- preorder :: Eq a => LatticeSyntax a -> LatticeSyntax a -> Bool
- satisfiable :: Eq a => LatticeSyntax a -> Bool

# Documentation

data LatticeSyntax a #

Constructors

LVar a |
LBound Bool |
LJoin (LatticeSyntax a) (LatticeSyntax a) |
LMeet (LatticeSyntax a) (LatticeSyntax a) |

Instances

Monad LatticeSyntax # |
Methods (>>=) :: LatticeSyntax a -> (a -> LatticeSyntax b) -> LatticeSyntax b # (>>) :: LatticeSyntax a -> LatticeSyntax b -> LatticeSyntax b # return :: a -> LatticeSyntax a # fail :: String -> LatticeSyntax a #
Functor LatticeSyntax # |
Methods fmap :: (a -> b) -> LatticeSyntax a -> LatticeSyntax b # (<$) :: a -> LatticeSyntax b -> LatticeSyntax a #
Applicative LatticeSyntax # |
Methods pure :: a -> LatticeSyntax a # (<*>) :: LatticeSyntax (a -> b) -> LatticeSyntax a -> LatticeSyntax b # (*>) :: LatticeSyntax a -> LatticeSyntax b -> LatticeSyntax b # (<*) :: LatticeSyntax a -> LatticeSyntax b -> LatticeSyntax a #
Foldable LatticeSyntax # |
Methods fold :: Monoid m => LatticeSyntax m -> m # foldMap :: Monoid m => (a -> m) -> LatticeSyntax a -> m # foldr :: (a -> b -> b) -> b -> LatticeSyntax a -> b # foldr' :: (a -> b -> b) -> b -> LatticeSyntax a -> b # foldl :: (b -> a -> b) -> b -> LatticeSyntax a -> b # foldl' :: (b -> a -> b) -> b -> LatticeSyntax a -> b # foldr1 :: (a -> a -> a) -> LatticeSyntax a -> a # foldl1 :: (a -> a -> a) -> LatticeSyntax a -> a # toList :: LatticeSyntax a -> [a] # null :: LatticeSyntax a -> Bool # length :: LatticeSyntax a -> Int # elem :: Eq a => a -> LatticeSyntax a -> Bool # maximum :: Ord a => LatticeSyntax a -> a # minimum :: Ord a => LatticeSyntax a -> a # sum :: Num a => LatticeSyntax a -> a # product :: Num a => LatticeSyntax a -> a #
Traversable LatticeSyntax # |
Methods traverse :: Applicative f => (a -> f b) -> LatticeSyntax a -> f (LatticeSyntax b) # sequenceA :: Applicative f => LatticeSyntax (f a) -> f (LatticeSyntax a) # mapM :: Monad m => (a -> m b) -> LatticeSyntax a -> m (LatticeSyntax b) # sequence :: Monad m => LatticeSyntax (m a) -> m (LatticeSyntax a) #
Eq a => Eq (LatticeSyntax a) # |
Methods (==) :: LatticeSyntax a -> LatticeSyntax a -> Bool # (/=) :: LatticeSyntax a -> LatticeSyntax a -> Bool #
Data a => Data (LatticeSyntax a) # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LatticeSyntax a -> c (LatticeSyntax a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (LatticeSyntax a) # toConstr :: LatticeSyntax a -> Constr # dataTypeOf :: LatticeSyntax a -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (LatticeSyntax a)) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (LatticeSyntax a)) # gmapT :: (forall b. Data b => b -> b) -> LatticeSyntax a -> LatticeSyntax a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LatticeSyntax a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LatticeSyntax a -> r # gmapQ :: (forall d. Data d => d -> u) -> LatticeSyntax a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> LatticeSyntax a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LatticeSyntax a -> m (LatticeSyntax a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LatticeSyntax a -> m (LatticeSyntax a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LatticeSyntax a -> m (LatticeSyntax a) #
Ord a => Ord (LatticeSyntax a) # |
Methods compare :: LatticeSyntax a -> LatticeSyntax a -> Ordering # (<) :: LatticeSyntax a -> LatticeSyntax a -> Bool # (<=) :: LatticeSyntax a -> LatticeSyntax a -> Bool # (>) :: LatticeSyntax a -> LatticeSyntax a -> Bool # (>=) :: LatticeSyntax a -> LatticeSyntax a -> Bool # max :: LatticeSyntax a -> LatticeSyntax a -> LatticeSyntax a # min :: LatticeSyntax a -> LatticeSyntax a -> LatticeSyntax a #
Read a => Read (LatticeSyntax a) # |
Methods readsPrec :: Int -> ReadS (LatticeSyntax a) # readList :: ReadS [LatticeSyntax a] # readPrec :: ReadPrec (LatticeSyntax a) # readListPrec :: ReadPrec [LatticeSyntax a] #
Show a => Show (LatticeSyntax a) # |
Methods showsPrec :: Int -> LatticeSyntax a -> ShowS # show :: LatticeSyntax a -> String # showList :: [LatticeSyntax a] -> ShowS #

dual :: LatticeSyntax a -> LatticeSyntax a #

freeVars :: LatticeSyntax a -> [a] #

equivalent :: Eq a => LatticeSyntax a -> LatticeSyntax a -> Bool #

Test for equivalence.

    >>> equivalent (LMeet (LVar 'a') (LVar 'b')) (LMeet (LVar 'b') (LVar 'a'))
    True

    >>> equivalent (LVar 'a') (LMeet (LVar 'a') (LVar 'a'))
    True

    >>> equivalent (LMeet (LVar 'a') (LVar 'b')) (LMeet (LVar 'b') (LVar 'b'))
    False

preorder :: Eq a => LatticeSyntax a -> LatticeSyntax a -> Bool #

Test for preorder.

     a ≤ b ⇔ a ∨ b ≡ b ⇔ a ≡ a ∧ b

    >>> preorder (LVar 'a' `LMeet` LVar 'b') (LVar 'a')
    True

    >>> preorder (LVar 'a') (LVar 'a' `LMeet` LVar 'b')
    False

satisfiable :: Eq a => LatticeSyntax a -> Bool #

Return `True` if for some variable assigment expression evaluates to `True`.