Skip to content

Unable to resolve instance for polykinded superclass constraint on associated-type-family.

The following program doesn't compile:

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PolyKinds        #-}
{-# LANGUAGE TypeFamilies     #-}

module Test where

class Back t

class Back (FrontBack t) => Front t where
  type FrontBack t :: k

instance Back Bool

instance Front Int where
  type FrontBack Int = Bool

with the error message:

    • No instance for (Back (FrontBack Int))
        arising from the superclasses of an instance declaration
    • In the instance declaration for ‘Front Int’

The example successfully compiles if the kind annotation on FrontBack is removed.

Edited by isovector
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information