Skip to content
Snippets Groups Projects
Commit 94522d99 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Add Text instance for License

Initially it's exactly the same format as Read/Show.
We can make it more liberal later.
parent a7c1b3cf
No related branches found
No related tags found
No related merge requests found
...@@ -205,7 +205,7 @@ basicFieldDescrs = ...@@ -205,7 +205,7 @@ basicFieldDescrs =
disp parseOptVersion disp parseOptVersion
packageVersion (\ver pkg -> pkg{package=(package pkg){pkgVersion=ver}}) packageVersion (\ver pkg -> pkg{package=(package pkg){pkgVersion=ver}})
, simpleField "license" , simpleField "license"
(text . show) parseLicenseQ disp parseLicenseQ
license (\l pkg -> pkg{license=l}) license (\l pkg -> pkg{license=l})
, simpleField "copyright" , simpleField "copyright"
showFreeText parseFreeText showFreeText parseFreeText
......
...@@ -49,6 +49,10 @@ module Distribution.License ( ...@@ -49,6 +49,10 @@ module Distribution.License (
License(..) License(..)
) where ) 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 -- |This datatype indicates the license under which your package is
-- released. It is also wise to add your license to each source file -- released. It is also wise to add your license to each source file
-- using the license-file field. The 'AllRightsReserved' constructor -- using the license-file field. The 'AllRightsReserved' constructor
...@@ -90,3 +94,6 @@ data License = ...@@ -90,3 +94,6 @@ data License =
| OtherLicense | OtherLicense
deriving (Read, Show, Eq) deriving (Read, Show, Eq)
instance Text License where
disp = Disp.text . show
parse = Parse.readS_to_P reads
...@@ -101,7 +101,7 @@ pkgDescrFieldDescrs = ...@@ -101,7 +101,7 @@ pkgDescrFieldDescrs =
(text . maybe "" show) (fmap Just parseReadSQ) (text . maybe "" show) (fmap Just parseReadSQ)
buildType (\t pkg -> pkg{buildType=t}) buildType (\t pkg -> pkg{buildType=t})
, simpleField "license" , simpleField "license"
(text . show) parseLicenseQ disp parseLicenseQ
license (\l pkg -> pkg{license=l}) license (\l pkg -> pkg{license=l})
, simpleField "license-file" , simpleField "license-file"
showFilePath parseFilePathQ showFilePath parseFilePathQ
......
...@@ -555,7 +555,7 @@ parseTestedWithQ = parseQuoted tw <++ tw ...@@ -555,7 +555,7 @@ parseTestedWithQ = parseQuoted tw <++ tw
return (compiler,version) return (compiler,version)
parseLicenseQ :: ReadP r License parseLicenseQ :: ReadP r License
parseLicenseQ = parseQuoted parseReadS <++ parseReadS parseLicenseQ = parseQuoted parse <++ parse
-- urgh, we can't define optQuotes :: ReadP r a -> ReadP r a -- urgh, we can't define optQuotes :: ReadP r a -> ReadP r a
-- because the "compat" version of ReadP isn't quite powerful enough. In -- because the "compat" version of ReadP isn't quite powerful enough. In
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment