Opened 3 years ago

Closed 2 years ago

#13364 closed task (duplicate)

Remove checkValidTelescope

Reported by: goldfire Owned by: goldfire
Priority: normal Milestone: 8.4.1
Component: Compiler Version: 8.0.1
Keywords: TypeInType Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


All of this new TypeInType nonsense has provided a number of ways that we can arrive at ill-scoped kinds. Let's assume we have

data SameKind :: k -> k -> Type

and then here are three subtly ill-scoped kinds:

forall a (b :: a) (c :: Proxy d). SameKind b d
forall a. forall (b :: a). forall (c :: Proxy d). SameKind b d
forall d. forall a (b :: a). SameKind b d

Despite the close similarity between these cases, they are all handled separately. See Note [Bad telescopes] in TcValidity for an overview, but these are spread between tcImplicitTKBndrsX, tcExplicitTKBndrsX, and those functions' calls to checkValidTelescope, checkZonkValidTelescope, and checkValidInferredKinds.

While I am unaware of a concrete bug this all causes, it's a mess.

Better would be to use the existing machinery to prevent skolem-escape: TcLevels and implication constraints. Specifically, it's quite plausible that all this can be avoided by a simple rule: bump the TcLevel (and create an implication constraint) for every new type variable brought into scope (including implicitly). (Actually, implicit variables have an implicit ordering that GHC is free to decide, so all implicitly bound variables should be brought into scope at once, with just one bump in the TcLevel.)

It might all just work! And then we can delete gobs of hairy code. Hooray!

Change History (4)

comment:1 Changed 3 years ago by goldfire

Owner: set to goldfire

comment:2 Changed 3 years ago by simonpj

Keywords: TypeInType added

comment:3 Changed 3 years ago by dfeuer

Milestone: 8.4.1

comment:4 Changed 2 years ago by goldfire

Resolution: duplicate
Status: newclosed

This is a dup of #14066. Closing, as that one has better commentary.

Note: See TracTickets for help on using tickets.