[Haskell-cafe] Haskell Debugging

Cale Gibbard cgibbard at gmail.com
Tue Nov 14 21:59:43 EST 2006

On 14/11/06, Cale Gibbard <cgibbard at gmail.com> wrote:
> On 14/11/06, Valentin Gjorgjioski <valentin.gjorgjioski at ijs.si> wrote:
> > Just one more thing
> >
> > If I write
> >
> > ex9 :: [Float]
> > ex9 = (observe "after reverse" )  reverse  [10.0,7.0,3.0,0.0,4.0]
> >
> > it doesn't work. If I delete ex9 :: [Float] then it works fine. any
> > suggestions?
> >
> This doesn't happen for me. The only thing I can think of trying is to
> check the type of ex9 by deleting the type signature, loading the
> file, and typing:
> :t ex9
> on the hugs prompt. If it prints anything other than
> ex9 :: [Float]
> then you'll have your answer.
>  - Cale
Sorry, I just realised what you meant, and I do get the behaviour you
initially described without the typesignature there.

Actually, without the typesignature, it's inferring the type [Double],
due to defaulting. However, adding the typesignature ex9 :: [Double]
will again cause it to print the values in the list rather than raw

So perhaps it's because you haven't given a typesignature explicitly,
so the list is initially polymorphic, which means that the values in
it are actually function calls initially (that is, things like
(fromRational 10.0)), and they only end up getting a specialised type
later, when hugs finishes compiling the module and applies the
monomorphism restriction and defaulting, but hugs isn't going back and
optimising the function with the additional knowledge? I don't really
know, that's my best guess at it.

Maybe someone who knows hugs better would know with more certainty?

 - Cale

More information about the Haskell-Cafe mailing list