Skip to content

Commit

Permalink
Handle licences starting with a digit
Browse files Browse the repository at this point in the history
cabal has a devscript that parses a json file (containing SPDX licences)
and returns a number of of Haskell data constructors.

There have been problems when the SPDX short identifier starts with
a digit (e.g. “0BSD”), as that would generate an data constructor
starting with a digit, which is not valid Haskell.
The way to handle such occourrences was in an ad-hoc basis.

This patch prepend “NN_” to the beginning of every SPDX licence starting
with a digit, future-proofing the script.
  • Loading branch information
ffaf1 committed Sep 14, 2024
1 parent efa04f7 commit e357e9f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cabal-dev-scripts/src/GenUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ toConstructorName t = t
f c = c

special :: Text -> Text
special "0BSD" = "NullBSD"
special "389_exception" = "DS389_exception"
special u = u
special u
| Just (c, _) <- T.uncons u
, C.isDigit c = "NN_" <> u
special u = u

mkList :: [Text] -> Text
mkList [] = " []"
Expand Down
11 changes: 11 additions & 0 deletions changelog.d/pr-10356
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: New licence constructors for SPDX licences starting with a digit
packages: Cabal-syntax
prs: #10356

description: {

- LicenseId constructor `NullBSD` is now `NN_0BSD`.
- LicenseId constructor `DS389_exception` is now and `NN_389_exception`.
- LicenseId constructor `X3D_Slicer_1_0` is now and `NN_3D_Slicer_1_0`.

}

0 comments on commit e357e9f

Please sign in to comment.