Skip to content

-XTypeInType uses up all memory when used in data family instance

Compiling this code with GHC 8.1 causes all my memory to be used very quickly:

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module TypeInTypeEatsAllMemory where

import Data.Kind

type Const a b = a

data family UhOh (f :: k1) (a :: k2) (b :: k3)
data instance UhOh (f :: * -> * -> *) (a :: forall a) (b :: Const * a) = UhOh

On the other hand, this code compiles without issue:

{-# LANGUAGE TypeInType #-}
module TypeInTypeEatsAllMemory where

import Data.Kind

type Const a b = a

data UhOh (f :: * -> * -> *) (a :: forall a) (b :: Const * a) = UhOh
Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC goldfire
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information