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?
Asked
Active
Viewed 2,082 times
0
-
2By "it won't load Prelude", do you mean that the prompt shows `ghci>` instead of `Prelude>`? If so, that is not a problem; the difference is just in appearance. – duplode Mar 14 '21 at 01:30
-
That's right, but how do I run the program then? In all instructions that I saw so far, you just need to type ghci, and then it should switch to Prelude> automatically, which doesnt happen in my case. I tried running the way it is now, but it woulnt work – DLaningham Mar 14 '21 at 03:45
-
1Try `ghci hello.hs"` when you start `ghci`, or `:l hello.hs` at the `ghci>` prompt. – chi Mar 14 '21 at 08:37
3 Answers
1
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.

duplode
- 33,731
- 7
- 79
- 150
0
If I type main into the console, then it works
ghci> main
"haskell"
name
"hi, name"
ghci>

DLaningham
- 23
- 6
-1
This might work
$ ghci
ghci> import Prelude
Prelude> printStrLn "Hello World!"
Hello World!
Prelude>
You may need to just run import Prelude
.

Iain
- 211
- 1
- 8
-
@DLaningham I am not familiar with Windows, could it be that the VSCode terminal is using a different terminal application than what you installed GHC on? – Iain Mar 14 '21 at 04:11
-
2(1) It is highly unlikely that the Prelude is actually not being loaded at the OP's prompt; all signs point to a [XY problem](https://meta.stackexchange.com/questions/66377). (2) Even if the Prelude weren't being loaded, `import Prelude` wouldn't change the prompt text from `ghci> ` (a fixed string) to `Prelude> ` (the list of loaded modules). (3) You meant `putStrLn` rather than `printStrLn` (I know it's just a typo, but it is a confusing one for someone completely new to the language like the OP). – duplode Mar 14 '21 at 13:50