[Haskell-cafe] Generalization of types during inference

Olaf Klinke olf at aatal-apotheke.de
Sun Jun 7 20:18:36 UTC 2020


> f 0 x = 0
> f 1 x = f 0 ()
> f n x = f (n-1) 'a'

That's very interesting, I learned something new about GHC today. I
used to believe that my Haskell compiler always type checks
declarations on its own, and after that unifies its result with the
type declaration that I provide. Polymorphic recursion yields a case
where the compiler's inference procedure is evidently not independent
of my provided type declaration. Can the above be abused to compile
programs containing false type declarations? (It seems the answer is
no, but maybe I lack the fantasy.)

Thanks,
Olaf



More information about the Haskell-Cafe mailing list