[Haskell-cafe] an evil type hangs GHC

Ryan Ingram ryani.spam at gmail.com
Fri Nov 12 16:53:53 EST 2010


>From http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/bugs.html#bugs-ghc:

GHC's inliner can be persuaded into non-termination using the standard
way to encode recursion via a data type:

  data U = MkU (U -> Bool)

  russel :: U -> Bool
  russel u@(MkU p) = not $ p u

  x :: Bool
  x = russel (MkU russel)


On Fri, Nov 12, 2010 at 10:52 AM, Petr Pudlak <deb at pudlak.name> wrote:
> Hi, I was playing with the following example I found in D.A.Turner's paper
> Total Functional Programming:
>
>> data Bad a = C (Bad a -> a)
>>
>> bad1 :: Bad a -> a
>> bad1 b@(C f) = f b
>>
>> bad2 :: a
>> bad2 = bad1 (C bad1)
>
> To my surprise, instead of creating a bottom valued function (an infinite
> loop), I managed to send the GHC compiler (ver. 6.12.1) to an infinite loop.
> Could anybody suggest an explanation? Is this a GHC bug? Or is this "Bad"
> data type so evil that type checking fails?
>
>    Thanks,
>    Petr
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQEcBAEBAgAGBQJM3Y0FAAoJEC5dcKNjBzhn68cH/3NsoUWOheGXsjZqpYj5yp5F
> IvN7NabyrAf3nxHG5uvIRqS0U33t0wZj3xSetnzDFW6wAjVtaDR4Jo7jB2/xXhLb
> g+vN9pcyZXH/r6HPb0ozRMHva4rS6K1S5T9u0kHI8jF9oeml4/lJQDOj2oouFfn2
> yxsW8FKSfYQaDfudI2Bap3mCl8xeKaABwWIcc+4LUU0r2nmpHxBlqet9yOTBAa57
> RkQrMmpt11bEVs/OUBZ2uIbd8iRD51eYTPyMHqy14a1FaRvkAvYinXQPSbg2vYcP
> YEH2llj/hsi7oxK4LVSj85nk0Ss59qFasYdWEPmr3zLzlRSjSI9kIlM3MqTjil4=
> =R7yy
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


More information about the Haskell-Cafe mailing list