Take the 2-minute tour ×

When using GHCi I'd like to know how can I use the -Wall option when (re)loading from the prompt.

For example in section 3.3 of Haskell Programming Tips The example shown with guards is as follows:

-- Bad implementation:
fac :: Integer -> Integer
fac n | n == 0 = 1

-- Slightly improved implementation:
fac :: Integer -> Integer
fac n | n == 0    = 1
      | otherwise = n * fac (n-1)


I know I can type ghci -Wall some_file.hs from the command line but once in the prompt I'm unsure how to check for warnings if I wish to reload.

I can't seem to find the answer after trying to Google this!

Thanks in advance!

share|improve this question
You can put it into your .ghci file for convenience. I have :set -Wall\n :set -fno-warn-type-defaults\n :set -fno-warn-unused-do-bind to turn on all but the annoying warnings. –  Daniel Fischer Nov 9 '12 at 1:57
If you set -Wall the first time, I think it'll stay set for any reloads, too... –  Ben Millwood Nov 9 '12 at 21:12

1 Answer 1

up vote 12 down vote accepted

In ghci, enter

:set -Wall

and if you want to turn all warnings off, you can do

:set -w

(Note the lowercase w. Uppercase would be turn normal warnings on.)

In the user guide it says we can use any ghc command line options at the command prompt as long as they're listed as dynamic, and we can see from the flag reference that all the warnings settings are dynamic.

Here's an example session, using the "bad implementation" above:

Prelude> :l temp.hs
[1 of 1] Compiling Main             ( temp.hs, interpreted )
Ok, modules loaded: Main.
(0.11 secs, 6443184 bytes)

*Main> :set -Wall

*Main> :l temp.hs
[1 of 1] Compiling Main             ( temp.hs, interpreted )

    Warning: Pattern match(es) are non-exhaustive
             In an equation for `fac': Patterns not matched: _

Ok, modules loaded: Main.
(0.14 secs, 6442800 bytes)
share|improve this answer

Your Answer


