Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#13603 closed bug (fixed)

Can't resolve levity polymorphic superclass

Reported by: Iceland_jack Owned by:
Priority: normal Milestone: 8.2.1
Component: Compiler Version: 8.0.1
Keywords: LevityPolymorphism, TypeInType Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_compile/T13603
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3489
Wiki Page:

Description

This works

{-# Language PolyKinds, TypeInType #-}

import GHC.Exts (TYPE, RuntimeRep)

class        A (a :: TYPE rep)
class A a => B (a :: TYPE rep)

instance A b => A (a -> (b :: TYPE rep))
instance B b => B (a -> b)

but the moment you add (b :: TYPE rep) to the last line it stops working

-- t3I7.hs:9:10-40: error: …
--     • Could not deduce (A b)
--         arising from the superclasses of an instance declaration
--       from the context: B b
--         bound by the instance declaration at /tmp/t3I7.hs:9:10-40
--     • In the instance declaration for ‘B (a -> b)’
-- Compilation failed.

{-# Language PolyKinds, TypeInType #-}

import GHC.Exts (TYPE, RuntimeRep)

class        A (a :: TYPE rep)
class A a => B (a :: TYPE rep)

instance A b => A (a -> (b :: TYPE rep))
instance B b => B (a -> (b :: TYPE rep))

Change History (8)

comment:1 Changed 7 months ago by goldfire

Seems to be fixed in HEAD; I can't reproduce.

comment:2 Changed 7 months ago by RyanGlScott

Differential Rev(s): Phab:D3489
Milestone: 8.2.1
Status: newpatch

It works in GHC 8.2 too! Commit b207b536ded40156f9adb168565ca78e1eef2c74 (Generalize kind of the (->) tycon) was what fixed it. I've added a regression test in Phab:D3489.

comment:3 Changed 7 months ago by Iceland_jack

Fantastic, I have to get the latest version

comment:4 Changed 7 months ago by Ryan Scott <ryan.gl.scott@…>

In ab27fdcf/ghc:

Add regression test for #13603

Summary:
Commit b207b536ded40156f9adb168565ca78e1eef2c74 (#11714) happened to
fix #13603 as well. Let's add a regression test so that it stays fixed.

Test Plan: make test TEST=T13603

Reviewers: bgamari, austin, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13603

Differential Revision: https://phabricator.haskell.org/D3489

comment:5 Changed 7 months ago by RyanGlScott

Status: patchmerge
Test Case: typecheck/should_compile/T13603

comment:6 Changed 7 months ago by bgamari

Resolution: fixed
Status: mergeclosed

comment:7 Changed 7 months ago by Iceland_jack

Out of curiosity, can any of those TYPE rep annotations be omitted in HEAD while retaining levity polymorphism?

comment:8 Changed 7 months ago by goldfire

I doubt it. Levity polymorphism is opt-in.

Note: See TracTickets for help on using tickets.