.ghci runs after flag parsing?

Evan Laforge qdunkan at gmail.com
Thu Apr 5 04:04:04 UTC 2018


I just noticed that it appears flag parsing happens before executing
.ghci.  And sure enough, looking at the source, GHCi.UI.runGHCi
executes the dot files, which is definitely after all the dynflags
parsing stuff in Main.

This means that if your .ghci has a -Wall, you can't turn off warnings
from the command line.  You have to prepend ":set " to the flags and
make a local ./.ghci, or pass -ghci-script.

I assume this has how it's already been, and I'm surprised it's taken
me this long to notice this!  Is there a good reason to do it this
way, or is it just the way it's always been and no one complained?
It's surprising to me because I think most programs do it the other
way.  E.g. when you start your shell, settings on the command line
will override your .zshrc or whatever.  zsh for one doesn't seem to
clearly document this, but experimenting seems to indicate that is so.

I can put all my flags in a -ghci-script without too much trouble,
it's just a surprising default.


More information about the Glasgow-haskell-users mailing list