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

WIP: GHC 8.2 revamp #182

Closed
wants to merge 2 commits into from
Closed

WIP: GHC 8.2 revamp #182

wants to merge 2 commits into from

Conversation

RyanGlScott
Copy link
Collaborator

Fixes #180 while I'm in town.

Copy link
Collaborator Author

@RyanGlScott RyanGlScott left a comment

Choose a reason for hiding this comment

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

Some concerns inline.

@@ -552,6 +554,7 @@ promotePat (DBangPa pat) = do
qReportWarning "Strict pattern converted into regular pattern in promotion"
(ty, pat') <- promotePat pat
return (ty, DBangPa pat')
promotePat (DSigPa _pat _ty) = error "TODO: Handle SigPa"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To be honest, I'm not quite sure how one would promote a DSigPa. Suggestions welcome.

@@ -499,6 +501,7 @@ singPat var_proms patCxt (DTildePa pat) = do
singPat var_proms patCxt (DBangPa pat) = do
(pat', ty) <- singPat var_proms patCxt pat
return (DBangPa pat', ty)
singPat _var_proms _patCxt (DSigPa _pat _ty) = error "TODO: Handle SigPa"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Similarly, how do we single DSigPas?

stock = case strat of
Nothing -> True
Just StockStrategy -> True
Just _ -> False
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I opted to only choose deriving clauses with an explicit strategy when that strategy is stock. We could make it more permissive and ignore the strategy, however.

Copy link
Owner

Choose a reason for hiding this comment

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

I agree with this choice.

-- implementation of permutations in base. However, it is needed
-- here, since (at least in GHC 8.2.1) the singletonized version
-- will fail to typecheck without it. See #13549 for the full story.
interleave' :: ([a] -> b) -> [a] -> [b] -> ([a], [b])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It turns out adding one type signature is enough to work around GHC Trac #13549. Hooray!

Copy link
Owner

Choose a reason for hiding this comment

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

See my comment to GHC's #13459. This type signature is indeed necessary: a type signature is required on a local function if its type is inferred differently depending on the presence of MonoLocalBinds. This is the case here.

@@ -1,3 +1,6 @@

Singletons/BadBoundedDeriving.hs:0:0: error:
Can't derive Bounded instance for Foo_0 a_1.
|
6 | $(singletons [d|
| ^^^^^^^^^^^^^^...
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think we should include these error message locations in golden files? They do add some degree of bloat.

@RyanGlScott
Copy link
Collaborator Author

Another TODO: the Travis build is failing because Cabal-2.0 is inclined to build the test suite before the library. Unfortunately, this breaks the assumption that "../dist/build/autogen/cabal_macros.h" will exist by the time the test suite is built (see this Travis error for an example).

Perhaps we should just make the test suite depend on singletons in singletons.cabal? Then again, there's this Note:

-- Note [-this-unit-id hack]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- We want to avoid installing singletons package before running the
-- testsuite, because in this way we prevent double compilation of the
-- library.

I don't think making the test suite depend on singletons in singletons.cabal would result in double compilation, but then again, I am quite new to the inner machinations of this test suite.

Copy link
Owner

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

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

This is a large patch. I will review when I have a bit more time than I do at the moment -- perhaps tomorrow. Many thanks for doing this!

-- implementation of permutations in base. However, it is needed
-- here, since (at least in GHC 8.2.1) the singletonized version
-- will fail to typecheck without it. See #13549 for the full story.
interleave' :: ([a] -> b) -> [a] -> [b] -> ([a], [b])
Copy link
Owner

Choose a reason for hiding this comment

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

See my comment to GHC's #13459. This type signature is indeed necessary: a type signature is required on a local function if its type is inferred differently depending on the presence of MonoLocalBinds. This is the case here.

@goldfirere
Copy link
Owner

Somehow just saw your last comment, about Cabal and -this-unit-id. It's quite possible that modern Cabals won't cause double-compilation.... or simply that we had configured it wrongly when setting this up. I don't think it would severely break things to add the singletons dependency.

@RyanGlScott
Copy link
Collaborator Author

OK, adding singletons as a test suite dependency seemed to fix that particular problem. But now the tests themselves are failing, apparently because of different unique values. But we enable -dsuppress-uniques... hm. I need to stare at this more closely.

@RyanGlScott
Copy link
Collaborator Author

Ah, here's a hunch. In the test suite, we do normalization with sed:

-- Note [Normalization with sed]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- Output file is normalized with sed. Line numbers generated in splices:
--
--   Foo:(40,3)-(42,4)
--   Foo.hs:7:3:
--   Equals_1235967303
--
-- are turned into:
--
--   Foo:(0,0)-(0,0)
--   Foo.hs:0:0:
--   Equals_0123456789

In particular, we normalize this pattern:

"-e", "'s/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/0123456789/g'"

This works assuming that whenever you have something like Equals_1235967303, it will always have exactly 10 numbers following it. But in GHC 8.2, uniques appear to have 19 numbers (perhaps due to this commit?). Maybe adding a pattern for 19 numbers will do the trick.

@RyanGlScott
Copy link
Collaborator Author

Luckily, adding more patterns for sed was precisely the secret sauce needed to cook up a green Travis build.

@RyanGlScott
Copy link
Collaborator Author

Should this be closed now that 637fb4d has been committed?

goldfirere pushed a commit that referenced this pull request May 31, 2017
The real work is in #182.
@goldfirere
Copy link
Owner

Don't close quite yet. I did merge (it passes the testsuite) but I haven't reviewed carefully yet. Will do so soon.

Copy link
Owner

@goldfirere goldfirere left a comment

Choose a reason for hiding this comment

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

Reviewed. Looks great. Thanks.

stock = case strat of
Nothing -> True
Just StockStrategy -> True
Just _ -> False
Copy link
Owner

Choose a reason for hiding this comment

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

I agree with this choice.

@goldfirere
Copy link
Owner

This has been merged.

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