spdx-0.0.1.0: SPDX license expression language

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

Distribution.SPDX

Contents

Description

 

Synopsis

Types

Data

licenseIdentifiers :: [LicenseId] Source

A list of SPDX licenses identifiers.

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

Ranges

lookupLicenseRange :: LicenseId -> [LicenseId] Source

Lookup newer licenses we know about

>>> lookupLicenseRange "MIT"
["MIT"]
>>> lookupLicenseRange "GPL-2.0"
["GPL-2.0","GPL-3.0"]
>>> lookupLicenseRange "LGPL-2.0"
["LGPL-2.0","LGPL-2.1","LGPL-3.0"]

Parsing

parseExpression :: String -> [LicenseExpression] Source

Parse SPDX License Expression

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

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