Load existing module

Hello! I have a file in my recent documents that I wish to load into my terminal.

I’ve tried to type :l “filename.hs” but it doesn’t work. Any ideas what I’ve done wrong? I’m on a MacBook btw.

1 Like

Is your file in the same folder you started ghci from?

If not, give an absolute/relative path to it, like

λ> :load …/prova.hs

I’m not sure if I fully understand. My file is in my “recent documents” and I run Haskell through Visual Studio Code. What do you mean by “the same folder you started ghci from”? I’m sorry for my incompetence, I have like 1,5 week of programming for newbies in my backpack.

Ah sorry I thought you were using ghci. I have never used Visual Studio Code, but hold tight, some Win user will respond.

When you start a terminal, including the terminal in visual studio code, it will be operating in a particular directory. You can type pwd, which stands for “print working directory” to see which directory you are in. You can type ls to see the contents of the current directory, and cd <directory name> to Change Directory to a different one.

The terminal doesn’t know anything about “recent documents”, this is a feature that only really exists in the GUI. In order to load a file in ghci, you need to be in the directory that the file is in. You may need to use the above commands to navigate to the appropriate directory. Then you can type ghci filename.hs, or simply ghci, and then :l filename.hs once you’re inside ghci.

For future reference, when asking for help, it’s usually a good idea to copy and paste the specific error you get, as “it doesn’t work” isn’t very descriptive. Having the specific error makes it easier to remotely debug the problem.


In Visual Studio Code, instead of File - Open File … use File - Open Folder …

Select the folder in which your code is located. You should have a list on the left-hand side of Visual Studio Code.

Now open a new terminal, Terminal - New Terminal, which should open in the folder which you selected. You can now use PowerShell to compile code / manage files and / or type ghci to get the standard REPL and/or use Stack or Cabal to manage and build your projects.

You can also add more terminals or split an existing terminal so that you can have multiple terminals open at once.