Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Fix #1015 with dataConUserTyVars #1022

Merged
merged 1 commit into from
Feb 4, 2019
Merged

Fix #1015 with dataConUserTyVars #1022

merged 1 commit into from
Feb 4, 2019

Conversation

RyanGlScott
Copy link
Member

(This is a second attempt at #1016, but targeted against ghc-head this time.)

The central trick in this patch is to use dataConUserTyVars instead of univ_tvs ++ ex_tvs, which displays the foralls in a GADT constructor in a way that's more faithful to how the user originally wrote it. With these changes, the example from #1015 now renders as:

haddock

Along the way, I simplified some code that tried to calculate where a data constructor should use GADT syntax in an ad hoc fashion. Luckily, this information is cached as isGadtSyntaxTyCon, so I just used that instead.

Thankfully, there's already a test case in html-test that stress-tests this code path, so I didn't need to add the test case from #1015 (since it relies on code from base which might change in the future).

@RyanGlScott
Copy link
Member Author

I'm currently relying on Travis to validate the test suite, since I'm unable to run it myself:

$ cabal new-test all -w ~/Software/ghc3/inplace/bin/ghc-stage2 --allow-newer
Build profile: -w ghc-8.7.20190204 -O1
In order, the following will be built (use -v for more details):
 - haddock-2.22.0 (test:hoogle-test) (first run)
 - haddock-2.22.0 (test:html-test) (first run)
 - haddock-2.22.0 (test:hypsrc-test) (first run)
 - haddock-2.22.0 (test:latex-test) (first run)
 - haddock-api-2.22.0 (test:spec) (first run)
 - haddock-library-1.8.0 (test:spec) (first run)
Preprocessing test suite 'hypsrc-test' for haddock-2.22.0..
Preprocessing test suite 'html-test' for haddock-2.22.0..
Building test suite 'hypsrc-test' for haddock-2.22.0..
Building test suite 'html-test' for haddock-2.22.0..
Preprocessing test suite 'hoogle-test' for haddock-2.22.0..
Building test suite 'hoogle-test' for haddock-2.22.0..
Preprocessing test suite 'latex-test' for haddock-2.22.0..
Building test suite 'latex-test' for haddock-2.22.0..
Running 1 test suites...
Test suite latex-test: RUNNING...
Running 1 test suites...
Running 1 test suites...
Test suite html-test: RUNNING...
Test suite hoogle-test: RUNNING...
Running 1 test suites...
Test suite hypsrc-test: RUNNING...
Haddock version 2.22.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.7.20190204
Generating documentation...
Failed to run Haddock on test package ''
Haddock output is at '/dev/null'. This file can be set with `--haddock-stdout`.
Testing output files...
html-test: html-test/out: getDirectoryContents:openDirStream: does not exist (No such file or directory)
Test suite html-test: FAIL
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-2.22.0/t/html-test/test/haddock-2.22.0-html-test.log
0 of 1 test suites (0 of 1 test cases) passed.
Haddock version 2.22.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.7.20190204
Generating documentation...
Failed to run Haddock on test package 'UnboxedStuff'
latex-test: latex-test/out/UnboxedStuff: removeDirectoryRecursive:getSymbolicLinkStatus: does not exist (No such file or directory)
Test suite latex-test: FAIL
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-2.22.0/t/latex-test/test/haddock-2.22.0-latex-test.log
0 of 1 test suites (0 of 1 test cases) passed.
Preprocessing test suite 'spec' for haddock-api-2.22.0..
Haddock version 2.22.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.7.20190204
Generating documentation...
Failed to run Haddock on test package 'type-sigs'
hoogle-test: hoogle-test/out/type-sigs: removeDirectoryRecursive:getSymbolicLinkStatus: does not exist (No such file or directory)
Test suite hoogle-test: FAIL
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-2.22.0/t/hoogle-test/test/haddock-2.22.0-hoogle-test.log
0 of 1 test suites (0 of 1 test cases) passed.
Building test suite 'spec' for haddock-api-2.22.0..
Haddock version 2.22.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.7.20190204
Generating documentation...
Failed to run Haddock on test package ''
Haddock output is at '/dev/null'. This file can be set with `--haddock-stdout`.
Testing output files...
hypsrc-test: hypsrc-test/out: getDirectoryContents:openDirStream: does not exist (No such file or directory)
Test suite hypsrc-test: FAIL
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-2.22.0/t/hypsrc-test/test/haddock-2.22.0-hypsrc-test.log
0 of 1 test suites (0 of 1 test cases) passed.
Running 1 test suites...
Test suite spec: RUNNING...

Haddock.Backends.Hyperlinker.Parser
  parse
    is total
      +++ OK, passed 100 tests.
    retains file layout
      +++ OK, passed 100 tests.
    when parsing single-line comments
      should ignore content until the end of line
      should allow endline escaping
    when parsing multi-line comments
      should support nested comments
      should distinguish compiler pragma
    should recognize preprocessor directives
    should distinguish basic language constructs
    should parse do-notation syntax

Finished in 0.7030 seconds
9 examples, 0 failures
Test suite spec: PASS
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-api-2.22.0/t/spec/test/haddock-api-2.22.0-spec.log
1 of 1 test suites (1 of 1 test cases) passed.
cabal: Tests failed for test:hoogle-test from haddock-2.22.0.
Tests failed for test:html-test from haddock-2.22.0.
Tests failed for test:hypsrc-test from haddock-2.22.0.
Tests failed for test:latex-test from haddock-2.22.0.

@harpocrates, do you know what might be causing this?

@harpocrates
Copy link
Collaborator

I was not aware of dataConUserTyVars! This patch is very helpful, thank you.


If your cabal version is new enough (perhaps even newer than what is currently released), there is a --test-option option that would let you thread through an argument to the Haddock test driver:

$ cabal new-test html-test -w ~/Software/ghc3/inplace/bin/ghc-stage2 \
                 --allow-newer --test-option='--haddock-stdout=html-test-out.log'
$ cat html-test-out.log

Not sure why Travis is taking so long to start the job. Perhaps I've been hammering CI with too much lately. I'll race Travis to test/accept locally.

@RyanGlScott
Copy link
Member Author

Unfortunately, --haddock-stdout doesn't appear to work for me:

$ /opt/cabal/head/bin/cabal new-test all -w ~/Software/ghc3/inplace/bin/ghc-stage2 --allow-newer --test-option='--haddock-stdout=html-test-out.log'
Build profile: -w ghc-8.7.20190204 -O1
In order, the following will be built (use -v for more details):
 - haddock-2.22.0 (exe:haddock) (first run)
 - haddock-api-2.22.0 (test:spec) (first run)
 - haddock-library-1.8.0 (test:spec) (first run)
 - haddock-2.22.0 (test:latex-test) (first run)
 - haddock-2.22.0 (test:hypsrc-test) (first run)
 - haddock-2.22.0 (test:html-test) (first run)
 - haddock-2.22.0 (test:hoogle-test) (first run)
Configuring executable 'haddock' for haddock-2.22.0..
Preprocessing test suite 'spec' for haddock-library-1.8.0..
Preprocessing test suite 'spec' for haddock-api-2.22.0..
Building test suite 'spec' for haddock-library-1.8.0..
Building test suite 'spec' for haddock-api-2.22.0..
Preprocessing executable 'haddock' for haddock-2.22.0..
Building executable 'haddock' for haddock-2.22.0..
[1 of 1] Compiling Main             ( driver/Main.hs, /home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-2.22.0/x/haddock/build/haddock/haddock-tmp/Main.o )
Running 1 test suites...
Test suite spec: RUNNING...
spec: unrecognized option `--haddock-stdout=html-test-out.log'
Try `spec --help' for more information.
Test suite spec: FAIL
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-library-1.8.0/t/spec/test/haddock-library-1.8.0-spec.log
0 of 1 test suites (0 of 1 test cases) passed.
Linking /home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-2.22.0/x/haddock/build/haddock/haddock ...
Running 1 test suites...
Test suite spec: RUNNING...
spec: unrecognized option `--haddock-stdout=html-test-out.log'
Try `spec --help' for more information.
Test suite spec: FAIL
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-api-2.22.0/t/spec/test/haddock-api-2.22.0-spec.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:spec from haddock-api-2.22.0.
Tests failed for test:spec from haddock-library-1.8.0.

@harpocrates
Copy link
Collaborator

It only works on html-test, latex-test, hoogle-test, and hypsrc-test, hence why I suggested you do do cabal new-test html-test -w ~/Software/ghc3/inplace/bin/ghc-stage2 --allow-newer --test-option='--haddock-stdout=html-test-out.log'

@RyanGlScott
Copy link
Member Author

Ack, reading is hard. Sorry for being dense.

At least now it's failing with a different error:

$ /opt/cabal/head/bin/cabal new-test html-test -w ~/Software/ghc3/inplace/bin/ghc-stage2 --allow-newer --test-option='--haddock-stdout=html-test-out.log'
Build profile: -w ghc-8.7.20190204 -O1
In order, the following will be built (use -v for more details):
 - haddock-2.22.0 (test:html-test) (first run)
Preprocessing test suite 'html-test' for haddock-2.22.0..
Building test suite 'html-test' for haddock-2.22.0..
Running 1 test suites...
Test suite html-test: RUNNING...
Haddock version 2.22.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
8.7.20190204
Generating documentation...
Failed to run Haddock on test package ''
Haddock output is at 'html-test-out.log'. This file can be set with `--haddock-stdout`.
Testing output files...
html-test: html-test/out: getDirectoryContents:openDirStream: does not exist (No such file or directory)
Test suite html-test: FAIL
Test suite logged to:
/home/rgscott/Documents/Hacking/Haskell/haddock/dist-newstyle/build/x86_64-linux/ghc-8.7.20190204/haddock-2.22.0/t/html-test/test/haddock-2.22.0-html-test.log
0 of 1 test suites (0 of 1 test cases) passed.
cabal: Tests failed for test:html-test from haddock-2.22.0.

@harpocrates
Copy link
Collaborator

Looks like the same error message to me... However, this time you should have a slightly more helpful html-test-out.log file that was written out. Perhaps that has some clues?

@RyanGlScott
Copy link
Member Author

Ah, indeed I do!

haddock: internal error: /home/rgscott/Software/ghc3/libraries/array/dist-install/doc/html/array/array.haddock: openBinaryFile: does not exist (No such file or directory)

OK, now I think I see what's going on. I had build GHC using the quick build flavour (using the old Make-based build system), which skips building Haddock. In retrospect, this was a terrible idea, since Haddock's tests assume that all of GHC's boot libraries have been Haddocked! I'll do that and try again.

@harpocrates
Copy link
Collaborator

Just ran tests locally, and it looks like everything already passes. 😄

I'll wait for CI to catch up before merging though.

Once Hi Haddock gets merged, it'll be worth combing over Convert and adding more tests. For the time being, testing these code paths is a serious PITA.

@RyanGlScott
Copy link
Member Author

Woohoo! I managed to get the testsuite to pass just as you posted that :)

@harpocrates harpocrates merged commit 44226fc into ghc-head Feb 4, 2019
@harpocrates harpocrates deleted the T1015-take-two branch February 4, 2019 20:18
@harpocrates
Copy link
Collaborator

CI agreed this doesn't break anything, so I merged.

Thanks again Ryan for all of these subtle fixes - they are very much appreciated.

@harpocrates harpocrates mentioned this pull request Sep 13, 2019
4 tasks
alanz pushed a commit that referenced this pull request Mar 25, 2020
The central trick in this patch is to use `dataConUserTyVars` instead of
`univ_tvs ++ ex_tvs`, which displays the foralls in a GADT constructor in
a way that's more faithful to how the user originally wrote it.

Fixes #1015.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants