Cant load Prelude in ghci interpreter in VS code

2.6k Views Asked by At

I have installed Haskell platform following the instructions on chocolatey and haskell.org. I am using Windows 10. My hello.hs program complies in command prompt, but when I try to do the same in VS code, it won't load Prelude, which I assume is necessary for running Haskell programs. I think it might be a configuration problem, but I cant find any useful documentation on it. How could I fix this and turn on Prelude? Are the problems that VS code shows relevant to this problem?

Pewlude not showing up Problems in VS code

3

There are 3 best solutions below

2
On

This might work

$ ghci
ghci> import Prelude
Prelude> printStrLn "Hello World!"
Hello World!
Prelude>

You may need to just run import Prelude.

0
On

Nothing looks wrong in your screenshots. The prompt text is ghci> rather than Prelude> because GHCi no longer defaults to showing the loaded modules on the prompt (see the GHC 9.0.1 changelog. Prelude is being loaded regardless. The warning shown in the IDE is a style suggestion that is inconsequential for the purpose of getting your code to run. As chi suggests, :l hello.hs at the GHCi prompt should be enough to have it loaded.

0
On

If I type main into the console, then it works

ghci> main
"haskell"
 name
 "hi, name"
 ghci>