Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action/Server refactors #391

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Profpatsch
Copy link
Contributor

A bunch of refactors that fell out of a study session of the module list generation code.

The original goal (at Munihac) was to change the sort order, so that the home module of a target is listed first, but we didn’t get that far.

So this is a bunch of refactors that do not (or should not) change any behavior. Any changes will be submitted in separate PRs.

@Profpatsch
Copy link
Contributor Author

cc @smatting

Copy link
Owner

@ndmitchell ndmitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for the PR! I suggest I review/land this one first, before looking at the others, so we can get through them in order. Let me know if that doesn't seem reasonable.

A few notes - I think the use of Wall makes the code worse in a few ways, but better in a bunch, so I think just winding back a few of them makes sense. Overall, looks good and some nice improvements. Thanks!

@@ -1,7 +1,10 @@
{-# LANGUAGE ViewPatterns, TupleSections, RecordWildCards, ScopedTypeVariables, PatternGuards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiWayIf #-}
{-# OPTIONS_GHC -Wall #-}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally find this a bad thing to put in the source code directly - what is in Wall changes, and not all the things in there are a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t want to fix warnings in the whole codebase for now, so I only scoped it to this module; do you want to just remove -Wall or have something else in mind?

Copy link
Contributor Author

@Profpatsch Profpatsch Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted for manually disabling the shadowing warnings & pattern warnings again

where k = key x

data UrlOpts = IsHaddockUrl | IsLocalUrl | IsOtherUrl
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great if this data type had some comments as to what each of the types of url looked like or represented (I appreciate this was missing before, but now we have the type, it should be easy to add)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t actually know what these mean semantically, I just refactored. I’ll leave it up to you to document the cases :)

@Profpatsch Profpatsch force-pushed the action-server-refactors branch from 1cf7774 to 10ecb58 Compare November 2, 2022 15:05
@Profpatsch
Copy link
Contributor Author

Okay, I addressed all the comments I think.

@Profpatsch Profpatsch force-pushed the action-server-refactors branch from 10ecb58 to 612583a Compare November 2, 2022 15:06
@Profpatsch Profpatsch requested a review from ndmitchell November 3, 2022 08:03
@ndmitchell
Copy link
Owner

I seem to be getting failures on newer GHC:

src/Action/Server.hs:217:21: error: [-Wincomplete-uni-patterns, -Werror=incomplete-uni-patterns]
Error:     Pattern match(es) are non-exhaustive
    In a lambda abstraction:
        Patterns of type ‘[Target]’ not matched: []
    |
217 |     forM_ results $ \is@(Target{..}:_) -> do
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^...

Happy with removing the wall, or fixing it. Also wouldn't be averse to using NonEmpty in the right places to fix it too.

@Profpatsch
Copy link
Contributor Author

Ah yeah, must have improved the exhaustiveness checking. Will fix

@Profpatsch
Copy link
Contributor Author

I opted for removing -Wall for now since I think it would interfere with the other PR’s commits too much and lead to a big rebase.

@Profpatsch
Copy link
Contributor Author

ok looks like the others are unrelated

on MacOS:

FAILED ON MAC
{"message":"API rate limit exceeded for 199.7.166.17. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}

on Ubuntu:

cabal: Failed to build wai-logger-2.4.0. The failure occurred during the
configure step. The exception was:
dieVerbatim: user error (cabal: '/home/runner/.ghcup/bin/ghc' exited with an
error:
/home/runner/.cabal/store/ghc-9.0.2/cabal-doctest-1.0.9-c5067c39fbeb5bff36b6ed7706ee31a87e1421142e9fe6d94eb8209fc65f5188/lib/libHScabal-doctest-1.0.9-c5067c39fbeb5bff36b6ed7706ee31a87e1421142e9fe6d94eb8209fc65f5188.a(Doctest.o)(.text+0x3066):
error: undefined reference to
'base_GHCziShow_zdfShowZLz2cUZRzuzdcshowList1_closure'
…

The `local` and `haddock` booleans are only used for determining the
URLs to generate, so let’s make that clear.
The function does not really deduplicate the elements, it takes and
groups. :)
Upstream does not think shadowing should be avoided, so let’s undo the
changes to shadowing.
Same with incomplete pattern warnings, we’ll just let it crash for
now.

Also drop the `Is*` prefix for the URL constructors.
CI unfortunately uses -Werror and tests against more modern versions
of GHC, so any new errors will only appear on CI.
@Profpatsch Profpatsch force-pushed the action-server-refactors branch from eac22f7 to efd152e Compare March 19, 2023 16:25
@Profpatsch
Copy link
Contributor Author

Okay, I might have some time to work on these again, I rebased. I think most of the comments have been fixed, PTAL.

@Profpatsch
Copy link
Contributor Author

Now all CI runs fail because of the copyright year :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants