[Haskell-beginners] Useful set of -W switches for .ghci?

Daniel Fischer daniel.is.fischer at web.de
Fri Dec 5 13:58:07 EST 2008


Am Freitag, 5. Dezember 2008 19:03 schrieb Александър Л. Димитров:
> Hey list,
>
> I'm currently using :set -Wall in my .ghci to enforce some good coding
> practices on my side. Something like missing type signatures and the like.
> It has saved me quite a lot of hassle over the last couple of days as I
> experimented more with Haskell. But it seems, -Wall may be just a little
> too… overzealous:
>
> Prelude> 2^2
>
>     Warning: Defaulting the following constraint(s) to type `Integer'
>              `Num t' arising from a use of `^' at <interactive>:1:0-2
>
>     Warning: Defaulting the following constraint(s) to type `Integer'
>              `Integral t' arising from a use of `^' at <interactive>:1:0-2
>
>     Warning: Defaulting the following constraint(s) to type `Integer'
>              `Num t' arising from a use of `^' at <interactive>:1:0-2
>
>     Warning: Defaulting the following constraint(s) to type `Integer'
>              `Integral t' arising from a use of `^' at <interactive>:1:0-2
> 4
>
> (I've shortened ghci's response a bit)
>
> So, do you have a good (recommended) set of -W switches for a newbie
> playing around in GHCi, so I can learn a good style? Forgive me if it's
> somewhere on page one of some book or tutorials - I've read so many of
> both, I'm beginning to forget things.
>

Turn off those warnings you don't want, like

$ ghci -Wall -fno-warn-type-defaults
GHCi, version 6.8.3: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude> 2^2
4

A list of warning options is in section 5.7 of the user's guide (unless it's 
moved in the 6.10 branch).

> Thanks,
> Aleks

Cheers,
Daniel



More information about the Beginners mailing list