Skip to content

Allow associated types in Minimal pragmas

Missing associated type definitions can cause compile-time problems similar to the run-time problems that occur when necessary methods are missing.

{-# language TypeFamilies, UndecidableInstances #-}

class Foo a where
  type X a
  type X a = Y a

  type Y a
  type Y a = X a

instance Foo Int

bob :: X Int
bob = undefined

Compiling this gives

Minim.hs:14:7: error:
    • Reduction stack overflow; size = 201
      When simplifying the following type: Y Int
      Use -freduction-depth=0 to disable this check
      (any upper bound you could choose might fail unpredictably with
       minor updates to GHC, so disabling the check is recommended if
       you're sure that type checking should terminate)
    • In the expression: undefined
      In an equation for ‘bob’: bob = undefined
   |
14 | bob = undefined

That's not exactly the best error message in the world. I would like to be able to write

  {-# MINIMAL X | Y #-}

which would mean that instances should give type instances for X or Y. I don't see any reason to prohibit mixing associated types and methods in a single MINIMAL pragma.

Trac metadata
Trac field Value
Version 8.4.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information