Rework Template Haskell's handling of strictness
ClosedPublic

Authored by RyanGlScott on Dec 11 2015, 11:36 PM.

Details

Summary

Currently, Template Haskell's treatment of strictness is not enough to
cover all possible combinations of unpackedness and strictness. In addition,
it isn't equipped to deal with new features (such as -XStrictData) which can
change a datatype's fields' strictness during compilation.

To address this, I replaced TH's Strict datatype with SourceUnpackedness
and SourceStrictness (which give the programmer a more complete toolkit to
configure a datatype field's strictness than just IsStrict, IsLazy, and
Unpack). I also added the ability to reify a constructor fields' strictness
post-compilation through the reifyConStrictness function.

Fixes Trac #10697.

Test Plan

./validate

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
RyanGlScott retitled this revision from to Rework Template Haskell's handling of strictness.Dec 11 2015, 11:36 PM
RyanGlScott updated this object.
RyanGlScott edited the test plan for this revision. (Show Details)
RyanGlScott updated the Trac tickets for this revision.

Eep, the Harbormaster build failure is a bit scary. I wanted to deprecate strictType, varStrictType, etc., but I didn't anticipate the rippling effect of warnings the DEPRECATE pragmas would have. Is there a better way to achieve what I'm trying to do?

Eep, the Harbormaster build failure is a bit scary. I wanted to deprecate strictType, varStrictType, etc., but I didn't anticipate the rippling effect of warnings the DEPRECATE pragmas would have. Is there a better way to achieve what I'm trying to do?

@goldfire, what is your usual policy when it comes to deprecation in TH?

RyanGlScott updated this revision to Diff 5650.Dec 13 2015, 4:16 PM
  • Silence warnings, make qReifyConStrictness take a Name argument
RyanGlScott updated this revision to Diff 5651.Dec 13 2015, 4:31 PM
  • Rebase on top of master
RyanGlScott updated this revision to Diff 5652.Dec 13 2015, 5:23 PM
  • Tidy up tests
goldfire accepted this revision.Dec 14 2015, 8:14 AM

LGTM. Thanks.

compiler/typecheck/TcSplice.hs
1343

Is dataConSrcBangs always accurate? Even across modules? I'd be a bit surprised if this information is persisted in interface files, as it's not really necessary (other than for printing in GHCi, which might be reason enough).

docs/users_guide/7.12.1-notes.rst
163

Oops.

This revision is now accepted and ready to land.Dec 14 2015, 8:14 AM
RyanGlScott added inline comments.Dec 14 2015, 10:55 AM
compiler/typecheck/TcSplice.hs
1343

I would presume it's accurate across modules, since (1) GHCi needs it, as you mentioned, and (2) T10697_source (which imports data types from T10697_sourceUtil) checks that reifying Bang is deterministic. Unless you had a more nuanced scenario in mind?

  • Remove merge conflict detritus
RyanGlScott updated this revision to Diff 5683.Dec 14 2015, 2:12 PM

Rebase on Top of Master Pt 2.: Electric Boogaloo

  • Tame some tests that went wild

@RyanGlScott, let me know when you would like me to review this.

I had quite a bit of trouble getting Harbormaster to build it correctly, but now it's finally green. It's now ready for further review.

Still looks good to me. Especially if it validates.

compiler/typecheck/TcSplice.hs
1343

No, that sounds sufficient. I was just worried that GHCi might be lying. Because you're right that GHCi needs this. (I suppose if GHCi lies, we can, too.)

bgamari accepted this revision.Dec 15 2015, 3:13 PM

Looks good to me. Thanks @RyanGlScott!

RyanGlScott planned changes to this revision.Dec 21 2015, 3:00 PM

This commit conflicts quite a bit with this, so give me a bit of time to resolve merge conflicts...

RyanGlScott updated this revision to Diff 5930.Dec 21 2015, 4:55 PM
  • Post-rebase cleanup
This revision is now accepted and ready to land.Dec 21 2015, 4:55 PM
RyanGlScott updated this revision to Diff 5932.Dec 21 2015, 5:46 PM
  • Adjust ghci library based on my changes

There we go, all green. It should be ready to land now.

This revision was automatically updated to reflect the committed changes.