[GHC] #14260: Type family in instance signature confuses GHC
GHC
ghc-devs at haskell.org
Thu Sep 21 00:45:34 UTC 2017
#14260: Type family in instance signature confuses GHC
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
You //almost// pulled the wool over my eyes and made me think that GHC was
infinitely looping without provocation. But then I realized that you
conveniently left off some important language extensions needed to compile
this code :)
{{{#!hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
}}}
The fact that you have to enable `UndecidableInstances` should be an
important clue as to what's happening. You have these two type family
instances:
{{{#!hs
type T () = T (W ())
type T (W a) = T a
}}}
So if you have `u :: T (W ()) -> () -> (); u = undefined`, GHC attempts to
generalize the type `T (W ()) -> () -> ()`, and thus reduce `T (W ())`.
But that means:
{{{
T (W ())
-> T ()
-> T (W ())
-> ...
}}}
Bam. Stack overflow. So I claim there is no bug here, only reckless use of
`UndecidableInstances` and type families.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14260#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list