spdx-0.2.1.0: SPDX license expression language

Copyright(c) 2015 Oleg Grenrus
LicenseBSD3
MaintainerOleg Grenrus <oleg.grenrus@iki.fi>
Safe HaskellSafe
LanguageHaskell98

Data.SPDX

Contents

Description

 

Synopsis

Types

Data

licenses :: [(LicenseId, String, Bool)] Source

A list of LicenseId, license name and whether the license is OSI approved.

See http://spdx.org/licenses/.

licenseIdentifiers :: [LicenseId] Source

A list of SPDX licenses identifiers.

See http://spdx.org/licenses/.

mkLicenseId :: String -> Maybe LicenseId Source

Lookup LicenseId by string representation

Ranges

lookupLicenseRange :: LicenseId -> [LicenseId] Source

Lookup newer licenses we know about

>>> lookupLicenseRange $ fromJust $ mkLicenseId "MIT"
[LicenseId "MIT"]
>>> lookupLicenseRange $ fromJust $ mkLicenseId "GPL-2.0"
[LicenseId "GPL-2.0",LicenseId "GPL-3.0"]
>>> lookupLicenseRange $ fromJust $ mkLicenseId "LGPL-2.0"
[LicenseId "LGPL-2.0",LicenseId "LGPL-2.1",LicenseId "LGPL-3.0"]

Parsing

parseExpression :: String -> [LicenseExpression] Source

Parse SPDX License Expression

>>> parseExpression "LGPL-2.1 OR MIT"
[EDisjunction (ELicense False (Right (LicenseId "LGPL-2.1")) Nothing) (ELicense False (Right (LicenseId "MIT")) Nothing)]

Prettifying

Inverse of parsing

Logic

satisfies Source

Arguments

:: LicenseExpression

package license

-> LicenseExpression

license policy

-> Bool 
⟦ satisfies a b ⟧ ≡ a ≥ b ≡ a ∧ b = b
>>> unsafeParseExpr "GPL-3.0" `satisfies` unsafeParseExpr "ISC AND MIT"
False
>>> unsafeParseExpr "Zlib" `satisfies` unsafeParseExpr "ISC AND MIT AND Zlib"
True
>>> unsafeParseExpr "(MIT OR GPL-2.0)" `satisfies` unsafeParseExpr "(ISC AND MIT)"
True
>>> unsafeParseExpr "(MIT AND GPL-2.0)" `satisfies` unsafeParseExpr "(MIT AND GPL-2.0)"
True
>>> unsafeParseExpr "(MIT AND GPL-2.0)" `satisfies` unsafeParseExpr "(ISC AND GPL-2.0)"
False

equivalent :: LicenseExpression -> LicenseExpression -> Bool Source

Check wheather two LicenseExpression are equivalent.

>>> unsafeParseExpr "(MIT AND GPL-2.0)" `equivalent` unsafeParseExpr "(GPL-2.0 AND MIT)"
True
>>> unsafeParseExpr "MIT" `equivalent` unsafeParseExpr "MIT OR BSD-3-Clause"
False