WIP: Notify user when a kind mismatch holds up a type family reduction
Needs RevisionPublic

Authored by v0d1ch on Jul 6 2018, 5:23 PM.

Details

Reviewers
goldfire
bgamari
Trac Issues
#10789
Summary

Improves the error while reducing type family and encountering invisible param

Test Plan

T10789.hs

v0d1ch created this revision.Jul 6 2018, 5:23 PM
v0d1ch added inline comments.Jul 6 2018, 5:28 PM
compiler/types/FamInstEnv.hs
1133

If I got this right then the next step is to connect the dots to the mkExpectedActualMsg which seems to be where the error is printed. This step is what I am stuck on currently.

I like the way you've made a new datatype to capture the result of reduceTyFamApp, but I think you will need to modify the code in the Unify module to really get this right. The approach you're taking here around invisible arguments does not look like it will work out. Thanks for posting this and starting work here!

compiler/typecheck/TcFlatten.hs
1718

Why change to Either? It doesn't look like the Left value is ever used.

1757

Ditto here.

compiler/types/FamInstEnv.hs
131

Good to make a new datatype around this.

133

Though this is a nitpick, I don't love the word "error" as used around here. There's no error -- it's just a type family that doesn't reduce (yet). "Stuck" maybe?

134

1-indexed or 0-indexed? 1 is probably better, but the comment should say.

1080

I don't think you meant to add this line.

1103

There should be a comment on TyFamAppErr explaining that 0 means something else strange happened. But I wonder if this code shouldn't be replaced by a panic -- I don't think this would ever happen.

1133

This looks like it blames the first invisible argument, regardless of the type family and its arguments. Why isn't the problem a visible argument? Why is it the first invisible one?

compiler/types/Type.hs
1414 ↗(On Diff #17228)

This won't work in general, because an invisible argument might be the same as a visible one.

v0d1ch updated this revision to Diff 17252.Jul 10 2018, 2:21 AM

Fix number of lines warn in TcErrors.hs

Fix small typo
Rename TyFamAppErr to TyFamAppStuck

v0d1ch updated this revision to Diff 17275.Jul 11 2018, 4:59 PM
  • Revert changes and start from scratch
v0d1ch updated this revision to Diff 17511.Jul 29 2018, 5:32 PM
  • Remove previous attempt
bgamari requested changes to this revision.Aug 21 2018, 11:01 AM
bgamari retitled this revision from Notify user when a kind mismatch holds up a type family reduction to WIP: Notify user when a kind mismatch holds up a type family reduction.
bgamari edited the summary of this revision. (Show Details)

@v0d1ch, is it safe to say this is still a work in progress?

This revision now requires changes to proceed.Aug 21 2018, 11:01 AM

@bgamari Yes! I was busy with https://phabricator.haskell.org/D5040 and now I can dedicate my spare time to this task.

v0d1ch updated this revision to Diff 18111.Sep 24 2018, 4:30 AM
  • Rebase new master
v0d1ch updated this revision to Diff 18143.Sep 28 2018, 8:43 AM
  • submodule revert
v0d1ch updated this revision to Diff 18399.Oct 22 2018, 5:40 AM
  • Update some code with master
bgamari requested changes to this revision.Jan 20 2019, 7:12 PM

What is the status of this, @v0d1ch?

This revision now requires changes to proceed.Jan 20 2019, 7:12 PM

@bgamari I didn’t get very far. I will try to get some help on the irc once I get hold of my machine from the repair