Search code examples
haskellcabal

How can you pre-load a module when invoking `cabal repl`?


Is there a way to have a module automatically load when cabal repl shows the ready prompt? I'd like to shortcut the following workflow with some command line options or something equivalent for cabal repl:

cabal repl
ghci> :m + Note.Query
... now I do stuff with functions in the Note.Query module

Solution

  • You can put the command :m + Note.Query in a file called .ghci. If there is a file called .ghci in the current directory, then it will be run when you invoke GHCi. If there is no .ghci file in the current directory, but there is one in your home directory, then that will be run. This allows you to have project-specific .ghci files.