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

Tc gets in an Infinite Loop #35

Open
fxdpntthm opened this issue May 9, 2022 · 2 comments
Open

Tc gets in an Infinite Loop #35

fxdpntthm opened this issue May 9, 2022 · 2 comments
Labels
question Further information is requested

Comments

@fxdpntthm
Copy link
Collaborator

fxdpntthm commented May 9, 2022

type family Loop where
   Loop = [Loop]

qqqq :: Loop -> Int
qqqq _ = 3

type checker loops while elaborating of type signature of qqqq.

@jgbm
Copy link
Contributor

jgbm commented May 9, 2022

It sure does.

This is essentially the pay-off of the discussion at the bottom of page 8 of constrained type families:

We can add the instance

instance Loopy ⇒ Loopy where
   type Loop = [Loop]

but it is clear that the Loopy constraint cannot be satisfied. Thus, any attempt to use this Loop
equation must be guarded by an unsatisfiable Loopy constraint, and so cannot compromise type
safety.

If you were to add that instance, then instance solving could (hypothetically) diverge—as it would attempt to solve Loopy using the instance Loopy ⇒ Loopy forever. With our implementation, we're accomplishing the same thing.

This is kinda what I mean when I say that we have all the pain of CTF, but none of the payoff. We expect Loop to be unusuable in our system, and indeed it is.........

@fxdpntthm fxdpntthm added the question Further information is requested label May 9, 2022
@fxdpntthm
Copy link
Collaborator Author

fxdpntthm commented May 9, 2022

I see, I changed the definition for it to be an associated type:

class Loopy where 
  type Loop

instance Loopy where
  type Loop = [Loop]

also diverges
and so does

instance Loopy => Loopy where
  type Loop = [Loop]

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

No branches or pull requests

2 participants