Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GHC 8.0.1 hangs. Explanation or compiler bug?

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 _ = ()
like image 555
Clinton Avatar asked Aug 22 '16 17:08

Clinton


1 Answers

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 _ _ _ = ()
like image 61
dfeuer Avatar answered Nov 16 '22 00:11

dfeuer