[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Improve docs on closed type families in hs-boots

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue May 21 09:09:12 UTC 2024



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
071d7a1e by Rodrigo Mesquita at 2024-05-20T10:55:16-04:00
Improve docs on closed type families in hs-boots

Fixes #24776

- - - - -
d9e2c119 by Torsten Schmits at 2024-05-20T10:55:52-04:00
Use default deviation for large-project test

This new performance test has the purpose of detecting regressions in
complexity in relation to the number of modules in a project, so 1%
deviation is way too small to avoid false positives.

- - - - -
1dc8bc19 by David Binder at 2024-05-21T05:09:05-04:00
haddock: Fix the testsuites of the haddock-library

- Apply all the metadata revisions from Hackage
  to the cabal file.
- Fix the `ParserSpec.hs` file in the `spec`
  testsuite of haddock-library.
- Make `CHANGES.md` an extra-doc-file instead of
  an extra-source-file.

- - - - -
7a8088a3 by David Binder at 2024-05-21T05:09:05-04:00
haddock: Fix parser of @since pragma

The testsuite contained tests for annotations of
the form `@since foo-bar-0.5.0`, but the parser was
written incorrectly.

- - - - -
20383f7f by Matthew Pickering at 2024-05-21T05:09:05-04:00
Fix nightly pages job

It seems likely broken by 9f99126a which moved `index.html` from the
root folder into `docs/` folder.

Fixes #24840

- - - - -


7 changed files:

- .gitlab-ci.yml
- docs/users_guide/exts/type_families.rst
- docs/users_guide/separate_compilation.rst
- testsuite/tests/perf/compiler/large-project/all.T
- utils/haddock/haddock-library/haddock-library.cabal
- utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
- utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -1065,7 +1065,7 @@ pages:
       <meta charset="UTF-8">
       <meta http-equiv="refresh" content="1; url=doc/">
       EOF
-    - cp -f index.html public/doc
+    - cp -f docs/index.html public/doc
   rules:
     # N.B. only run this on ghc/ghc since the deployed pages are quite large
     # and we only serve GitLab Pages for ghc/ghc.


=====================================
docs/users_guide/exts/type_families.rst
=====================================
@@ -415,10 +415,19 @@ left hand side of an equation can be explicitly bound, such as in: ::
 A closed type family may be declared with no equations. Such closed type
 families are opaque type-level definitions that will never reduce, are
 not necessarily injective (unlike empty data types), and cannot be given
-any instances. This is different from omitting the equations of a closed
-type family in a ``hs-boot`` file, which uses the syntax ``where ..``,
-as in that case there may or may not be equations given in the ``hs``
-file.
+any instances.
+
+In an ``hs-boot`` file, closed type families must either have the same
+equations as those in the source file, or you can use the following syntax to
+omit the equations (note the literal ``..``) ::
+
+  type family R a where ..
+
+In this case, the closed type family ``R`` matching this "boot" declaration may
+have any number of equations given in the source ``hs`` file (including zero).
+For more information on mutual recursive modules with ``hs-boot`` modules
+(including type families) see :ref:`mutual-recursion`.
+
 
 .. _type-family-examples:
 


=====================================
docs/users_guide/separate_compilation.rst
=====================================
@@ -729,8 +729,8 @@ be recompiled.
 
 .. _mutual-recursion:
 
-How to compile mutually recursive modules
------------------------------------------
+Mutually recursive modules and hs-boot files
+--------------------------------------------
 
 .. index::
    single: module system, recursion
@@ -851,8 +851,9 @@ A hs-boot file is written in a subset of Haskell:
 
 -  Open type and data family declarations are exactly as in Haskell.
 
--  A closed type family may optionally omit its equations, as in the
-   following example: ::
+-  A closed type family may either be given in full (where all equations must
+   match the source module), or it can be given abstractly using the ``where ..``
+   syntax (thus omitting the equations), as in the following example: ::
 
         type family ClosedFam a where ..
 


=====================================
testsuite/tests/perf/compiler/large-project/all.T
=====================================
@@ -7,7 +7,7 @@ def large_project_makedepend(num):
     return test(
         f'large-project-makedepend-{num}',
         [
-            collect_compiler_stats('bytes allocated', 1),
+            collect_compiler_stats('bytes allocated'),
             pre_cmd(f'./large-project.sh {num}'),
             extra_files(['large-project.sh']),
             ignore_stderr,


=====================================
utils/haddock/haddock-library/haddock-library.cabal
=====================================
@@ -30,8 +30,10 @@ tested-with:          GHC == 7.4.2
                     , GHC == 9.0.1
                     , GHC == 9.2.0
 
-extra-source-files:
+extra-doc-files:
   CHANGES.md
+
+extra-source-files:
   fixtures/examples/*.input
   fixtures/examples/*.parsed
 
@@ -86,19 +88,19 @@ test-suite spec
     Documentation.Haddock.Parser.Identifier
 
   build-depends:
-    , base-compat  ^>= 0.12.0
+    , base-compat  ^>= 0.12.0 || ^>= 0.13.0
     , QuickCheck   ^>= 2.11  || ^>= 2.13.2 || ^>= 2.14
-    , deepseq      ^>= 1.3.0.0 || ^>= 1.4.0.0
+    , deepseq      ^>= 1.3.0.0 || ^>= 1.4.0.0 || ^>=1.5.0.0
 
   -- NB: build-depends & build-tool-depends have independent
   --     install-plans, so it's best to limit to a single major
   --     version of `hspec` & `hspec-discover` to ensure
   --     intercompatibility
   build-depends:
-    , hspec                          >= 2.4.4    && < 2.10
+    , hspec                          >= 2.4.4    && < 2.12
 
   build-tool-depends:
-    , hspec-discover:hspec-discover  >= 2.4.4    && < 2.10
+    , hspec-discover:hspec-discover  >= 2.4.4    && < 2.12
 
 test-suite fixtures
   type:             exitcode-stdio-1.0
@@ -113,11 +115,11 @@ test-suite fixtures
     , base
 
       -- extra dependencies
-    , base-compat           ^>= 0.12.0
+    , base-compat           ^>= 0.12.0 || ^>=0.13.0
     , directory             ^>= 1.3.0.2
     , filepath              ^>= 1.4.1.2
-    , optparse-applicative  ^>= 0.15
-    , tree-diff             ^>= 0.2
+    , optparse-applicative  >= 0.15 && < 0.19
+    , tree-diff             ^>= 0.2 || ^>= 0.3
 
 source-repository head
   type:     git


=====================================
utils/haddock/haddock-library/src/Documentation/Haddock/Parser.hs
=====================================
@@ -28,7 +28,7 @@ import Control.Applicative
 import Control.Arrow (first)
 import Control.Monad
 import Data.Char (chr, isAlpha, isSpace, isUpper)
-import Data.List (elemIndex, intercalate, unfoldr)
+import Data.List (elemIndex, intercalate, unfoldr, intersperse)
 import Data.Maybe (fromMaybe, mapMaybe)
 import Data.Monoid
 import qualified Data.Set as Set
@@ -576,11 +576,12 @@ since = do
   return DocEmpty
   where
     version = do
-      pkg <- Parsec.optionMaybe $ Parsec.try $ package <* Parsec.char '-'
+      pkg <- Parsec.optionMaybe $ Parsec.try $ package
       ver <- decimal `Parsec.sepBy1` "."
       return (MetaSince pkg ver)
 
-    package = Parsec.many1 $ Parsec.alphaNum <|> Parsec.oneOf "_-"
+    package = combine <$> (Parsec.many1 (Parsec.letter <|> Parsec.char '_')) `Parsec.endBy1` (Parsec.char '-')
+    combine = concat . intersperse "-"
 
 -- | Headers inside the comment denoted with @=@ signs, up to 6 levels
 -- deep.


=====================================
utils/haddock/haddock-library/test/Documentation/Haddock/ParserSpec.hs
=====================================
@@ -26,12 +26,6 @@ instance IsString (Doc String) where
 instance IsString a => IsString (Maybe a) where
   fromString = Just . fromString
 
-emptyMeta :: Meta
-emptyMeta =
-  Meta
-    { _metaSince = Nothing
-    }
-
 parseParas :: String -> MetaDoc () String
 parseParas = overDoc Parse.toRegular . Parse.parseParas Nothing
 
@@ -543,21 +537,21 @@ spec = do
       it "adds specified version to the result" $ do
         parseParas "@since 0.5.0"
           `shouldBe` MetaDoc
-            { _meta = emptyMeta{_version = Just [0, 5, 0]}
+            { _meta = Meta{_metaSince = Just (MetaSince{sincePackage = Nothing, sinceVersion = [0, 5, 0]})}
             , _doc = DocEmpty
             }
 
       it "ignores trailing whitespace" $ do
         parseParas "@since 0.5.0 \t "
           `shouldBe` MetaDoc
-            { _meta = emptyMeta{_version = Just [0, 5, 0]}
+            { _meta = Meta{_metaSince = Just (MetaSince{sincePackage = Nothing, sinceVersion = [0, 5, 0]})}
             , _doc = DocEmpty
             }
 
       it "does not allow trailing input" $ do
         parseParas "@since 0.5.0 foo"
           `shouldBe` MetaDoc
-            { _meta = emptyMeta{_version = Nothing}
+            { _meta = Meta{_metaSince = Nothing}
             , _doc = DocParagraph "@since 0.5.0 foo"
             }
 
@@ -565,7 +559,7 @@ spec = do
         parseParas "@since foo-bar-0.5.0"
           `shouldBe` MetaDoc
             { _meta =
-                emptyMeta
+                Meta
                   { _metaSince =
                       Just $
                         MetaSince
@@ -573,7 +567,7 @@ spec = do
                           , sinceVersion = [0, 5, 0]
                           }
                   }
-            , _doc = DocParagraph "@since 0.5.0 foo"
+            , _doc = DocEmpty
             }
 
       context "when given multiple times" $ do
@@ -586,7 +580,7 @@ spec = do
               ]
             `shouldBe` MetaDoc
               { _meta =
-                  emptyMeta
+                  Meta
                     { _metaSince =
                         Just $
                           MetaSince



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd5bf17048600742124199385b770a99dc946f90...20383f7f89e708b4036d5b2c2a8663377cc74501

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd5bf17048600742124199385b770a99dc946f90...20383f7f89e708b4036d5b2c2a8663377cc74501
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240521/475a3e9c/attachment-0001.html>


More information about the ghc-commits mailing list