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.
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.
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.
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.
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 https://www.youtube.com/watch?v=7WxbuAztuFs&t=791s.
thanks for the quick answers , 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.