Skip to content

Deriving Foldable causes GHC to take a long time (GHC 8.0 ONLY)

This file never finishes compiling with optimization (-O) on GHC 8.0.1, and GHC 8.0.2 (dated 20161213):

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}

module Bug where
import Data.Typeable
import GHC.Generics
import Data.Data

data Condition v = Condition
    deriving (Functor, Foldable)

data CondTree v c a = CondNode
    { condTreeData        :: a
    , condTreeConstraints :: c
    , condTreeComponents  :: [CondBranch v c a]
    }
    deriving (Functor, Foldable)

data CondBranch v c a = CondBranch
    { condBranchCondition :: Condition v
    , condBranchIfTrue    :: CondTree v c a
    , condBranchIfFalse   :: Maybe (CondTree v c a)
    }
    deriving (Functor, Foldable)

The problem seems to be fixed in HEAD but I haven't looked for the commit that fixed it.

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