------------------------------------------------------------------------------- |-- Module : Distribution.License-- Copyright : Isaac Jones 2003-2005-- Duncan Coutts 2008---- Maintainer : cabal-devel@haskell.org-- Portability : portable---- The License datatype. For more information about these and other-- open-source licenses, you may visit <http://www.opensource.org/>.---- The @.cabal@ file allows you to specify a license file. Of course you can-- use any license you like but people often pick common open source licenses-- and it's useful if we can automatically recognise that (eg so we can display-- it on the hackage web pages). So you can also specify the license itself in-- the @.cabal@ file from a short enumeration defined in this module. It-- includes 'GPL', 'LGPL' and 'BSD3' licenses.{- All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Isaac Jones nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}moduleDistribution.License(License(..),knownLicenses,)whereimportDistribution.Version(Version(Version))importDistribution.Text(Text(..),display)importqualifiedDistribution.Compat.ReadPasParseimportqualifiedText.PrettyPrintasDispimportText.PrettyPrint((<>))importqualifiedData.CharasChar(isAlphaNum)-- |This datatype indicates the license under which your package is-- released. It is also wise to add your license to each source file-- using the license-file field. The 'AllRightsReserved' constructor-- is not actually a license, but states that you are not giving-- anyone else a license to use or distribute your work. The comments-- below are general guidelines. Please read the licenses themselves-- and consult a lawyer if you are unsure of your rights to release-- the software.--dataLicense=--TODO: * remove BSD4-- | GNU Public License. Source code must accompany alterations.GPL(MaybeVersion)-- | Lesser GPL, Less restrictive than GPL, useful for libraries.|LGPL(MaybeVersion)-- | 3-clause BSD license, newer, no advertising clause. Very free license.|BSD3-- | 4-clause BSD license, older, with advertising clause. You almost-- certainly want to use the BSD3 license instead.|BSD4-- | The MIT license, similar to the BSD3. Very free license.|MIT-- | Holder makes no claim to ownership, least restrictive license.|PublicDomain-- | No rights are granted to others. Undistributable. Most restrictive.|AllRightsReserved-- | Some other license.|OtherLicense-- | Not a recognised license.-- Allows us to deal with future extensions more gracefully.|UnknownLicenseStringderiving(Read,Show,Eq)knownLicenses::[License]knownLicenses=[GPLunversioned,GPL(version[2]),GPL(version[3]),LGPLunversioned,LGPL(version[2,1]),LGPL(version[3]),BSD3,BSD4,MIT,PublicDomain,AllRightsReserved,OtherLicense]whereunversioned=Nothingversionv=Just(Versionv[])instanceTextLicensewheredisp(GPLversion)=Disp.text"GPL"<>dispOptVersionversiondisp(LGPLversion)=Disp.text"LGPL"<>dispOptVersionversiondisp(UnknownLicenseother)=Disp.textotherdispother=Disp.text(showother)parse=doname<-Parse.munch1(\c->Char.isAlphaNumc&&c/='-')version<-Parse.optionNothing(Parse.char'-'>>fmapJustparse)return$!case(name,version::MaybeVersion)of("GPL",_)->GPLversion("LGPL",_)->LGPLversion("BSD3",Nothing)->BSD3("BSD4",Nothing)->BSD4("MIT",Nothing)->MIT("PublicDomain",Nothing)->PublicDomain("AllRightsReserved",Nothing)->AllRightsReserved("OtherLicense",Nothing)->OtherLicense_->UnknownLicense$name++maybe""(('-':).display)versiondispOptVersion::MaybeVersion->Disp.DocdispOptVersionNothing=Disp.emptydispOptVersion(Justv)=Disp.char'-'<>dispv