diff --git a/Distribution/InstalledPackageInfo.hs b/Distribution/InstalledPackageInfo.hs index 2274ac5e01f3de68594620f74cfb31339c942b26..83d2e1b39860ad9ca97fd462582f7c5b8be25e68 100644 --- a/Distribution/InstalledPackageInfo.hs +++ b/Distribution/InstalledPackageInfo.hs @@ -205,7 +205,7 @@ basicFieldDescrs = disp parseOptVersion packageVersion (\ver pkg -> pkg{package=(package pkg){pkgVersion=ver}}) , simpleField "license" - (text . show) parseLicenseQ + disp parseLicenseQ license (\l pkg -> pkg{license=l}) , simpleField "copyright" showFreeText parseFreeText diff --git a/Distribution/License.hs b/Distribution/License.hs index 10a9bd2f086561c316985f493f859d98eb708751..8966678adcd0da0e5e8941ea858b7757365a5abd 100644 --- a/Distribution/License.hs +++ b/Distribution/License.hs @@ -49,6 +49,10 @@ module Distribution.License ( License(..) ) where +import Distribution.Text (Text(..)) +import qualified Distribution.Compat.ReadP as Parse +import qualified Text.PrettyPrint as Disp + -- |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 @@ -90,3 +94,6 @@ data License = | OtherLicense deriving (Read, Show, Eq) +instance Text License where + disp = Disp.text . show + parse = Parse.readS_to_P reads diff --git a/Distribution/PackageDescription/Parse.hs b/Distribution/PackageDescription/Parse.hs index c8c48b704d919cf0be83cdd147d57365bea4ec55..8a67c4fb8369d6fd222485e3319e31b7c3f01f21 100644 --- a/Distribution/PackageDescription/Parse.hs +++ b/Distribution/PackageDescription/Parse.hs @@ -101,7 +101,7 @@ pkgDescrFieldDescrs = (text . maybe "" show) (fmap Just parseReadSQ) buildType (\t pkg -> pkg{buildType=t}) , simpleField "license" - (text . show) parseLicenseQ + disp parseLicenseQ license (\l pkg -> pkg{license=l}) , simpleField "license-file" showFilePath parseFilePathQ diff --git a/Distribution/ParseUtils.hs b/Distribution/ParseUtils.hs index 4a339e557c3e6bac97ab44106dd11771b8b6ea66..cb91783093cec95dd7eb61dad03cfef3b6338109 100644 --- a/Distribution/ParseUtils.hs +++ b/Distribution/ParseUtils.hs @@ -555,7 +555,7 @@ parseTestedWithQ = parseQuoted tw <++ tw return (compiler,version) parseLicenseQ :: ReadP r License -parseLicenseQ = parseQuoted parseReadS <++ parseReadS +parseLicenseQ = parseQuoted parse <++ parse -- urgh, we can't define optQuotes :: ReadP r a -> ReadP r a -- because the "compat" version of ReadP isn't quite powerful enough. In