Haskell newbie, trying to get Haskell to work in vscode for over a Week

Hi everyone :slight_smile:

Sorry but i want to learn Haskell, buit just trying to get it started and working properly in vscode seems almost impossible and has got me to the point of wanting to give it up already. Am i just really dumb? or is this a normal experience? I learned Java core a long Time ago and have basically forgotten more than i remember, that is the extent of my Programming history basically.

Thanks for any advice on how to move forward.!!

1 Like

Can you say what instructions you have followed, what you have done so far, and a description of what is not working?

Hi,

well i followed instructions on adding ghc on my Computer and then setting it up on vscode with lint and Haskell highlighting and so on. But i am having lost of trouble trying to test any code in vs. For instance i see using "Stack ghci src\lib.hs should be then showing in the Terminal *lib and not GHCI, but i don’t get that for instance.
In lost of tutorials the trainer is just addin in one bit of code after the other and being able to test it directly like this code
"module Lib(someFunc
) where
someFunc :: IO()
someFunc = putStrLn “not so easy”

triple :: Integer → Integer
triple x = x * 3" so as far as i understan i should now be able to write triple 2 for instance and see 6 returned, but it doesn’t work? I instead get an error that it is spelled wrong or not found?
I hope this is making sense to you lol.

Which instructions are you talking about? Can you provide a link to the instructions you are following?

Can you please copy and paste the exact text of the error message, otherwise it’s very hard to help.

1 Like

I wrote a little guide. I’d recommend using ghcup for managing all necessary tools, and cabal as a build tool instead of stack but that’s up to you. If you are using stack, be sure you configure it properly.

1 Like

I used mainly this video → https://www.youtube.com/watch?v=7WxbuAztuFs

Hi Tomjaguarpaw,
this is what i get in the Terminal.
D:\TestHaskell\Homework101>stack build --fast
Homework101-0.1.0.0: unregistering (local file changes: src\Lib.hs)
Homework101> configure (lib + exe)
Configuring Homework101-0.1.0.0…
Homework101> build (lib + exe)
Preprocessing library for Homework101-0.1.0.0…
Building library for Homework101-0.1.0.0…
[1 of 2] Compiling Paths_Homework101 [Optimisation flags changed]
[2 of 2] Compiling Lib

src\Lib.hs:8:1: warning: [-Wunused-top-binds]
Defined but not used: `triple’
|
8 | triple x = x * 3
| ^^^^^^
Preprocessing executable ‘Homework101-exe’ for Homework101-0.1.0.0…
Building executable ‘Homework101-exe’ for Homework101-0.1.0.0…
[1 of 2] Compiling Main [Optimisation flags changed]
[2 of 2] Compiling Paths_Homework101 [Optimisation flags changed]
Linking .stack-work\dist\d53b6a14\build\Homework101-exe\Homework101-exe.exe …
Homework101> copy/register
Installing library in D:\TestHaskell\Homework101.stack-work\install\fc9eea00\lib\x86_64-windows-ghc-9.0.2\Homework101-0.1.0.0-LIyOgfgoz6bIJVvKkSOcAK
Installing executable Homework101-exe in D:\TestHaskell\Homework101.stack-work\install\fc9eea00\bin
Registering library for Homework101-0.1.0.0…

D:\TestHaskell\Homework101>triple 4
Der Befehl “triple” ist entweder falsch geschrieben oder
konnte nicht gefunden werden. this says triple is written incorrectly or couldn’t be found.
I added everything that was in the Terminal maybe it can help you see what is not functioning correctly.

Hi Lsmor,

i will take a look at your guide :slight_smile: Thanks.

1 Like

Oh, you shouldn’t type triple 4 into the shell. Instead you should do stack ghci src/Lib.hs to get into GHCi, and when you at the GHCi prompt then you type triple 4. The video that you linked explains this at time 13:11 Learning Haskell Week 01 - Getting Started With Haskell Using VS Code (Updated) - YouTube.

Defined but not used: `triple’

This is just a warning. Nothing to worry about.

2 Likes

Hi Tom,

thanks for the quick answers :slight_smile: , i had tried this and it didn’t work but now, after restarting vsCode it worked… very strange. I will try to do further testing and hope it all works for now ! I am still trying to figure out how this system works so sorry for the stupid questions.

1 Like

That’s OK, I’m happy to help! Viel Glück, and if you have any more problems please come back to ask.

2 Likes