Why does this code using UndecidableInstances compile, then generate a runtime infinite loop?
问题 When writing some code using UndecidableInstances earlier, I ran into something that I found very odd. I managed to unintentionally create some code that typechecks when I believed it should not: {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-} data Foo = Foo class ConvertFoo a b where convertFoo :: a -> b instance (ConvertFoo a Foo, ConvertFoo Foo b) => ConvertFoo a b where convertFoo =