-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | SPDX license expression language
--   
--   Implementation of <a>SPDX</a> related functionality.
@package spdx
@version 0.2.1.0


-- | Inspired by <a>Simple SMT Solver</a>.
--   
--   In future this module will probably be moved into separate package.
module Data.SPDX.LatticeSyntax
data LatticeSyntax a
LVar :: a -> LatticeSyntax a
LBound :: Bool -> LatticeSyntax a
LJoin :: (LatticeSyntax a) -> (LatticeSyntax a) -> LatticeSyntax a
LMeet :: (LatticeSyntax a) -> (LatticeSyntax a) -> LatticeSyntax a
dual :: LatticeSyntax a -> LatticeSyntax a
freeVars :: LatticeSyntax a -> [a]

-- | Test for equivalence.
--   
--   <pre>
--   &gt;&gt;&gt; equivalent (LMeet (LVar 'a') (LVar 'b')) (LMeet (LVar 'b') (LVar 'a'))
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; equivalent (LVar 'a') (LMeet (LVar 'a') (LVar 'a'))
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; equivalent (LMeet (LVar 'a') (LVar 'b')) (LMeet (LVar 'b') (LVar 'b'))
--   False
--   </pre>
equivalent :: Eq a => LatticeSyntax a -> LatticeSyntax a -> Bool

-- | Test for preorder.
--   
--   <pre>
--   a ≤ b ⇔ a ∨ b ≡ b ⇔ a ≡ a ∧ b
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; preorder (LVar 'a' `LMeet` LVar 'b') (LVar 'a')
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; preorder (LVar 'a') (LVar 'a' `LMeet` LVar 'b')
--   False
--   </pre>
preorder :: Eq a => LatticeSyntax a -> LatticeSyntax a -> Bool

-- | Return <a>True</a> if for some variable assigment expression evaluates
--   to <a>True</a>.
satisfiable :: Eq a => LatticeSyntax a -> Bool
instance Data.Data.Data a => Data.Data.Data (Data.SPDX.LatticeSyntax.LatticeSyntax a)
instance Data.Traversable.Traversable Data.SPDX.LatticeSyntax.LatticeSyntax
instance Data.Foldable.Foldable Data.SPDX.LatticeSyntax.LatticeSyntax
instance GHC.Base.Functor Data.SPDX.LatticeSyntax.LatticeSyntax
instance GHC.Show.Show a => GHC.Show.Show (Data.SPDX.LatticeSyntax.LatticeSyntax a)
instance GHC.Read.Read a => GHC.Read.Read (Data.SPDX.LatticeSyntax.LatticeSyntax a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.SPDX.LatticeSyntax.LatticeSyntax a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.SPDX.LatticeSyntax.LatticeSyntax a)
instance GHC.Base.Applicative Data.SPDX.LatticeSyntax.LatticeSyntax
instance GHC.Base.Monad Data.SPDX.LatticeSyntax.LatticeSyntax
instance GHC.Base.Functor (Data.SPDX.LatticeSyntax.Eval v)
instance GHC.Base.Applicative (Data.SPDX.LatticeSyntax.Eval v)
instance GHC.Base.Alternative (Data.SPDX.LatticeSyntax.Eval v)
instance GHC.Base.Monad (Data.SPDX.LatticeSyntax.Eval v)
instance GHC.Base.MonadPlus (Data.SPDX.LatticeSyntax.Eval v)


module Data.SPDX

-- | Opaque license identifier type.
data LicenseId
getLicenseId :: LicenseId -> String

-- | Opaque license exception identifier type.
data LicenseExceptionId
getLicenseExceptionId :: LicenseExceptionId -> String
data LicenseRef
LicenseRef :: !(Maybe String) -> !String -> LicenseRef
[lrDocument] :: LicenseRef -> !(Maybe String)
[lrLicense] :: LicenseRef -> !String
data LicenseExpression
ELicense :: !Bool -> !(Either LicenseRef LicenseId) -> !(Maybe LicenseExceptionId) -> LicenseExpression
EConjunction :: !LicenseExpression -> !LicenseExpression -> LicenseExpression
EDisjunction :: !LicenseExpression -> !LicenseExpression -> LicenseExpression

-- | A list of <a>LicenseId</a>, license name and whether the license is
--   OSI approved.
--   
--   See <a>http://spdx.org/licenses/</a>.
licenses :: [(LicenseId, String, Bool)]

-- | A list of SPDX licenses identifiers.
--   
--   See <a>http://spdx.org/licenses/</a>.
licenseIdentifiers :: [LicenseId]

-- | Lookup <a>LicenseId</a> by string representation
mkLicenseId :: String -> Maybe LicenseId

-- | Whether license is OSI approved
--   
--   See <a>http://opensource.org/licenses/alphabetical</a>
isOsiApproved :: LicenseId -> Bool
licenseExceptions :: [LicenseExceptionId]
licenseRanges :: [[LicenseId]]

-- | Lookup newer licenses we know about
--   
--   <pre>
--   &gt;&gt;&gt; lookupLicenseRange $ fromJust $ mkLicenseId "MIT"
--   [LicenseId "MIT"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lookupLicenseRange $ fromJust $ mkLicenseId "GPL-2.0"
--   [LicenseId "GPL-2.0",LicenseId "GPL-3.0"]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; lookupLicenseRange $ fromJust $ mkLicenseId "LGPL-2.0"
--   [LicenseId "LGPL-2.0",LicenseId "LGPL-2.1",LicenseId "LGPL-3.0"]
--   </pre>
lookupLicenseRange :: LicenseId -> [LicenseId]

-- | Parse SPDX License Expression
--   
--   <pre>
--   &gt;&gt;&gt; parseExpression "LGPL-2.1 OR MIT"
--   [EDisjunction (ELicense False (Right (LicenseId "LGPL-2.1")) Nothing) (ELicense False (Right (LicenseId "MIT")) Nothing)]
--   </pre>
parseExpression :: String -> [LicenseExpression]
unsafeParseExpr :: String -> LicenseExpression
prettyLicenseId :: LicenseId -> String
prettyLicenseExceptionId :: LicenseExceptionId -> String
prettyLicenseRef :: LicenseRef -> String
prettyLicenseExpression :: LicenseExpression -> String

-- | <pre>
--   ⟦ satisfies a b ⟧ ≡ a ≥ b ≡ a ∧ b = b
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsafeParseExpr "GPL-3.0" `satisfies` unsafeParseExpr "ISC AND MIT"
--   False
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsafeParseExpr "Zlib" `satisfies` unsafeParseExpr "ISC AND MIT AND Zlib"
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsafeParseExpr "(MIT OR GPL-2.0)" `satisfies` unsafeParseExpr "(ISC AND MIT)"
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsafeParseExpr "(MIT AND GPL-2.0)" `satisfies` unsafeParseExpr "(MIT AND GPL-2.0)"
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsafeParseExpr "(MIT AND GPL-2.0)" `satisfies` unsafeParseExpr "(ISC AND GPL-2.0)"
--   False
--   </pre>
satisfies :: LicenseExpression -> LicenseExpression -> Bool

-- | Check wheather two <a>LicenseExpression</a> are equivalent.
--   
--   <pre>
--   &gt;&gt;&gt; unsafeParseExpr "(MIT AND GPL-2.0)" `equivalent` unsafeParseExpr "(GPL-2.0 AND MIT)"
--   True
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; unsafeParseExpr "MIT" `equivalent` unsafeParseExpr "MIT OR BSD-3-Clause"
--   False
--   </pre>
equivalent :: LicenseExpression -> LicenseExpression -> Bool
instance GHC.Read.Read Data.SPDX.Lic
instance GHC.Show.Show Data.SPDX.Lic
instance GHC.Classes.Ord Data.SPDX.Lic
instance GHC.Classes.Eq Data.SPDX.Lic
