| Copyright | (c) 2015 Oleg Grenrus |
|---|---|
| License | BSD3 |
| Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi> |
| Safe Haskell | None |
| Language | Haskell2010 |
Distribution.SPDX
Description
- type LicenseId = String
- type LicenseExceptionId = String
- data LicenseRef = LicenseRef {
- lrDocument :: !(Maybe String)
- lrLicense :: !String
- data LicenseExpression
- licenseIdentifiers :: [LicenseId]
- licenseExceptions :: [LicenseExceptionId]
- licenseRanges :: [[LicenseId]]
- lookupLicenseRange :: LicenseId -> [LicenseId]
- parseExpression :: String -> [LicenseExpression]
- unsafeParseExpr :: String -> LicenseExpression
- satisfies :: LicenseExpression -> LicenseExpression -> Bool
Types
type LicenseExceptionId = String Source
data LicenseRef Source
Constructors
| LicenseRef | |
Fields
| |
Instances
data LicenseExpression Source
Data
licenseIdentifiers :: [LicenseId] Source
A list of SPDX licenses identifiers.
Ranges
licenseRanges :: [[LicenseId]] Source
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
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