[Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals & multiplication)

Roel van Dijk vandijk.roel at gmail.com
Wed Oct 14 06:15:11 EDT 2009


On Wed, Oct 14, 2009 at 11:53 AM, Dan Doel <dan.doel at gmail.com> wrote:
> In fact, with GHC extensions, you don't need newtypes:
>  {-# LANGUAGE LiberalTypeSynonyms #-}
Ah, I completely forgot about that language extension. Thanks!

> Yeah. Asking for the type of 'f4 . f4' doesn't seem to expand the synonyms,
> while checking f5 does for some reason. I'm perplexed that having f5 defined
> in the file doesn't trigger the explosion unless you declare a type (even in
> terms of X and T) or ask for its type at the prompt.
If you declare a type for f5 then ghci must check if that type is
correct, which triggers the explosion. If you don't declare a type
then it won't infer the type until necessary. Basically, ghci is lazy
:-)


More information about the Haskell-Cafe mailing list