Skip to content

Typechecker loop with type families

The following code (which I think is ill-typed) causes GHC to hang, both on 6.12.1 and 6.13.20100616:

{-# LANGUAGE TypeFamilies, ScopedTypeVariables, FlexibleContexts #-}
module Crash where

class Family f where
  terms :: f a -> a

class Family (TermFamily a) => TermLike a where
  type TermFamily a :: * -> *

laws :: forall a b. TermLike a => TermFamily a a -> b
laws t = prune t (terms (undefined :: TermFamily a a))

prune :: TermLike a => TermFamily a a -> TermFamily a a -> b
prune = undefined

The compiler still hangs if I remove the typeclass constraints (everything to the left of a =>, I mean), but everything else seems to be necessary for the compiler to loop. Using -dshow-passes shows that it's the typechecker that loops.

Trac metadata
Trac field Value
Version 6.13
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
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