From d2d702759a74012e718ecdac1d7d98e9afd83d52 Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Sun, 10 Dec 2023 01:02:48 +0000 Subject: [PATCH] Fix #9507 Describe accurately acceptable package names --- doc/cabal-package-description-file.rst | 33 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/doc/cabal-package-description-file.rst b/doc/cabal-package-description-file.rst index ae07f3ff3bc..04575ea94ad 100644 --- a/doc/cabal-package-description-file.rst +++ b/doc/cabal-package-description-file.rst @@ -318,20 +318,33 @@ describe the package as a whole: tools require the package-name specified for this field to match the package description's file-name :file:`{package-name}.cabal`. - Package names are case-sensitive and must match the regular expression - (i.e. alphanumeric "words" separated by dashes; each alphanumeric - word must contain at least one letter): - ``[[:digit:]]*[[:alpha:]][[:alnum:]]*(-[[:digit:]]*[[:alpha:]][[:alnum:]]*)*``. + A valid package name comprises an alphanumeric 'word'; or two or more + such words separated by a hyphen/minus character (``-``). A word cannot be + comprised only of the characters ``0`` to ``9``. - Or, expressed in ABNF_: + An alphanumeric character is one in one of the Unicode Letter categories + (Lu (uppercase), Ll (lowercase), Lt (titlecase), Lm (modifier), or + Lo (other)) or Number categories (Nd (decimal), Nl (letter), or No (other)). + + Package names are case-sensitive. + + Expressed as a regular expression: + + ``[0-9]*[\p{L}\p{N}-[0-9]][\p{L}\p{N}]*(-[0-9]*[\p{L}\p{N}-[0-9]][\p{L}\p{N}]*)*`` + + Expressed in ABNF_: .. code-block:: abnf package-name = package-name-part *("-" package-name-part) - package-name-part = *DIGIT UALPHA *UALNUM + package-name-part = *DIGIT UALPHANUM-NOT-DIGIT *UALNUM - UALNUM = UALPHA / DIGIT - UALPHA = ... ; set of alphabetic Unicode code-points + DIGIT = %x30-39 ; 0-9 + + UALNUM = UALPHANUM-NOT-DIGIT / DIGIT + UALPHANUM-NOT-DIGIT = ... ; set of Unicode code-points in Letter or + ; Number categories, other than the DIGIT + ; code-points .. note:: @@ -1480,13 +1493,13 @@ system-dependent values for these fields. Version constraints use the operators ``==, >=, >, <, <=`` and a version number. Multiple constraints can be combined using ``&&`` or ``||``. - + .. Note:: Even though there is no ``/=`` operator, by combining operators we can skip over one or more versions, to skip a deprecated version or to skip versions that narrow the constraint solving more than we'd like. - + For example, the ``time =1.12.*`` series depends on ``base >=4.13 && <5`` but ``time-1.12.3`` bumps the lower bound on base to ``>=4.14``. If we still want to compile with a ``ghc-8.8.*`` version of GHC that ships with