Can someone explain why the following code causes GHC 8.0.1 to loop forever on compiling, or is this a bug?
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
main = return $ f (Just 'c')
data D1 x
data D2
type family TF x = t | t -> x
type instance TF (D1 x, a) = Maybe (TF (x, a))
type instance TF (D2, ()) = Char
f :: TF (x, a) -> ()
f _ = ()
The compiler falling into an infinite loop without UndecidableInstances
or UndecidableSuperclassCycles
is a compiler bug, as jberryman stated. You should report it on the GHC Trac site.
I simplified your example a bit, which may or may not clarify things and will likely make your bug report more effective.
{-# LANGUAGE TypeFamilyDependencies #-}
module TFLoop where
import Data.Proxy
main :: IO ()
main = return $ f Proxy Proxy (Just 'c')
data D1 x
data D2
type family TF d a = t | t -> d a
type instance TF (D1 x) a = Maybe (TF x a)
type instance TF D2 () = Char
f :: proxy1 x -> proxy2 a -> TF x a -> ()
f _ _ _ = ()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With