#if __GLASGOW_HASKELL__ >= 701
#endif
module Data.SPDX (
LicenseId
, getLicenseId
, LicenseExceptionId
, getLicenseExceptionId
, LicenseRef(..)
, LicenseExpression(..)
, licenses
, licenseIdentifiers
, mkLicenseId
, isOsiApproved
, licenseExceptions
, licenseRanges
, lookupLicenseRange
, parseExpression
, unsafeParseExpr
, prettyLicenseId
, prettyLicenseExceptionId
, prettyLicenseRef
, prettyLicenseExpression
, satisfies
, equivalent
) where
import Data.SPDX.LatticeSyntax (LatticeSyntax(..))
import qualified Data.SPDX.LatticeSyntax as LS
import Data.SPDX.Licenses
import Data.SPDX.Parser
import Data.SPDX.Pretty
import Data.SPDX.Ranges
import Data.SPDX.Types
data Lic = Lic (Either LicenseRef LicenseId) (Maybe LicenseExceptionId)
deriving (Eq, Ord, Show, Read)
exprToLSLic :: LicenseExpression -> LatticeSyntax Lic
exprToLSLic (ELicense False l e) = LVar (Lic l e)
exprToLSLic (ELicense True (Right l) e) = foldr1 LJoin $ map (\l' -> LVar $ Lic (Right l') e) $ lookupLicenseRange l
exprToLSLic (ELicense True (Left l) e) = LVar (Lic (Left l) e)
exprToLSLic (EConjunction a b) = LMeet (exprToLSLic a) (exprToLSLic b)
exprToLSLic (EDisjunction a b) = LJoin (exprToLSLic a) (exprToLSLic b)
satisfies :: LicenseExpression
-> LicenseExpression
-> Bool
satisfies a b = exprToLSLic b `LS.preorder` exprToLSLic a
equivalent :: LicenseExpression -> LicenseExpression -> Bool
equivalent a b = exprToLSLic a `LS.equivalent` exprToLSLic b