Skip to content

Commit

Permalink
Fix #9507 Describe accurately acceptable package names
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Dec 10, 2023
1 parent eeb99c9 commit 05305db
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
13 changes: 8 additions & 5 deletions doc/buildinfo-fields-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Field syntax is described as they are in the latest cabal file format version.

.. math::
\mathord{"}\mathtt{example}\mathord{"}
\mathord{``}\mathtt{example}\mathord{"}
* non-terminals are type set in italic:

Expand All @@ -25,13 +25,13 @@ Field syntax is described as they are in the latest cabal file format version.

.. math::
[ \mathord{"}\mathtt{1}\mathord{"} \cdots \mathord{"}\mathtt{9}\mathord{"} ]
[ \mathord{``}\mathtt{1}\mathord{"} \cdots \mathord{``}\mathtt{9}\mathord{"} ]
Character set complements have :math:`c` superscript:

.. math::
[ \mathord{"}\mathtt{1}\mathord{"} \cdots \mathord{"}\mathtt{9}\mathord{"} ]^c
[ \mathord{``}\mathtt{1}\mathord{"} \cdots \mathord{``}\mathtt{9}\mathord{"} ]^c
* repetition is type set using regular expression inspired notation.
Superscripts tell how many time to repeat:
Expand Down Expand Up @@ -134,10 +134,13 @@ hs-string
\mathop{\mathord{``}\mathtt{\text{"}}\mathord{"}}{\left\{ {[\mathop{\mathord{``}\mathtt{\text{"}}\mathord{"}}\mathop{\mathord{``}\mathtt{\text{\\}}\mathord{"}}]^c}\mid\left\{ \begin{gathered}\mathop{\mathord{``}\mathtt{\text{\\}\text{&}}\mathord{"}}\\\mathop{\mathord{``}\mathtt{\text{\\}\text{\\}}\mathord{"}}\\\left\{ \mathop{\mathord{``}\mathtt{\text{\\}n}\mathord{"}}\mid\mathop{\mathit{escapes}} \right\}\\\mathop{\mathord{``}\mathtt{\text{\\}}\mathord{"}}[\mathop{\mathord{``}\mathtt{0}\mathord{"}}\cdots\mathop{\mathord{``}\mathtt{9}\mathord{"}}]\\\mathop{\mathord{``}\mathtt{\text{\\}o}\mathord{"}}[\mathop{\mathord{``}\mathtt{0}\mathord{"}}\cdots\mathop{\mathord{``}\mathtt{7}\mathord{"}}]\\\mathop{\mathord{``}\mathtt{\text{\\}x}\mathord{"}}[\mathop{\mathord{``}\mathtt{0}\mathord{"}}\cdots\mathop{\mathord{``}\mathtt{9}\mathord{"}}\mathop{\mathord{``}\mathtt{A}\mathord{"}}\cdots\mathop{\mathord{``}\mathtt{F}\mathord{"}}\mathop{\mathord{``}\mathtt{a}\mathord{"}}\cdots\mathop{\mathord{``}\mathtt{f}\mathord{"}}]\\\left\{ \mathop{\mathord{``}\mathtt{\text{\\}\text{^}\text{@}}\mathord{"}}\mid\mathop{\mathit{control}} \right\}\\\left\{ \mathop{\mathord{``}\mathtt{\text{\\}NUL}\mathord{"}}\mid\mathop{\mathit{ascii}} \right\}\end{gathered} \right\} \right\}}^\ast_{}\mathop{\mathord{``}\mathtt{\text{"}}\mathord{"}}
unqual-name
Unqualified component names are used for package names, component names etc. but not flag names. Unqualified component name consist of components separated by dash, each component is non-empty alphanumeric string, with at least one alphabetic character. In other words, component may not look like a number.
Unqualified component names are used for package names, component names etc. but not flag names. An unqualified component name consists of components separated by a hyphen, each component is a non-empty alphanumeric string, with at least one character that is not the digits ``0`` to ``9``. In other words, a component may not look like a number.

.. math::
{\left({\mathop{\mathit{alpha\text{-}num}}}^\ast_{}\mathop{\mathit{alpha}}{\mathop{\mathit{alpha\text{-}num}}}^\ast_{}\right)}^+_{\mathop{\mathord{``}\mathtt{\text{-}}\mathord{"}}}
{\left({\mathop{\mathit{alpha\text{-}num}}}^\ast_{}{\mathop{\mathit{alpha\text{-}num\text{-}not\text{-}digit}}}\:{\mathop{\mathit{alpha\text{-}num}}}^\ast_{}\right)}^+_{\mathop{\mathord{``}\mathtt{\text{-}}\mathord{"}}}
.. math::
{\mathop{\mathit{alpha\text{-}num\text{-}not\text{-}digit}}} = {\mathop{\mathit{alpha\text{-}num}}}\cap{[ \mathord{``}\mathtt{0}\mathord{"} \cdots \mathord{``}\mathtt{9}\mathord{"} ]^c}
module-name
Haskell module name as recognized by Cabal parser.
Expand Down
37 changes: 26 additions & 11 deletions doc/cabal-package-description-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,24 +318,39 @@ 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 character (``-``). A word cannot be
comprised only of the digits ``0`` to ``9``.

Or, expressed in ABNF_:
An alphanumeric character belongs to 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::

Hackage restricts package names to the ASCII subset.
Hackage will not accept package names that use alphanumeric characters
other than ``A`` to ``Z``, ``a`` to ``z``, and ``0`` to ``9``
(the ASCII subset).

.. pkg-field:: version: numbers (required)

Expand Down Expand Up @@ -1480,13 +1495,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
Expand Down
2 changes: 1 addition & 1 deletion doc/package-concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Package names and versions
All packages have a name, e.g. "HUnit". Package names are assumed to be
unique. Cabal package names may contain letters, numbers and hyphens,
but not spaces and may also not contain a hyphened section consisting of
only numbers. The namespace for Cabal packages is flat, not
only of the digits ``0`` to ``9``. The namespace for Cabal packages is flat, not
hierarchical.

Packages also have a version, e.g "1.1". This matches the typical way in
Expand Down

0 comments on commit 05305db

Please sign in to comment.