Day 1: Haskell
TLDR : Getting started on the setup and installation
Note : I was thinking of doing 100 days of Haskell (I even put the “100daysofCode” tag for the bloody post), but I think I shall start small for now. Let’s start with this, then we’ll upgrade accordingly should I have the time (and inclination to do so).
One more disclaimer. I’m writing this as I’m doing it, so this is more of a diary than a tutorial. Drop me a message if I made a mistake that will ruin my life 20 years from now.
OS : Pop OS (Ubuntu and this are pretty much same. You can use commands for Ubuntu all the time)
Version : 21.04
Putting these here because if you have windows, some stuff will be different. So check accordingly.
- I visited this site and ran the following command.
sudo apt-get install haskell-platform
2. I also installed VScode (Visual Studio Code for the uninitiated, for whom I shall leave every stone unturned to not call plebs) as my code editor.
sudo apt-get install code
sudo snap install code
Didn’t install anything else. These two seem to be sufficient.
Note : I have installed extensions for VScode for haskell, but since I’m not using the VSCode terminal for running the program, they generally serve no purpose besides aesthetics. RGB code!
- I made a folder called haskell and opened the terminal in it.
(Right click → open in terminal)
- Started a new project in it and decided to call it playground.
stack new playground
3. After that, go into the playgrounds folder
4. Open it in VSCode
Since we’re only beginning, let's print Hello World.
- Go to the app folder and open Main.hs
- Have a look there and see if you can understand anything. If not, replace
main = blank (or whatever is on the RHS of this equation)
main = putStrLn "Hello World"
3. After saving the file, go back to the terminal and run the following two commands.
Note : It doesn’t seem like you need “stack build” now. “stack run” gave me the output anyway, even after changing the program (unlike java, where you need to recompile for every small change). However, the output doesn’t look clean, so I’ll recommend doing both.
4. Observe the output on your terminal and rejoice, you puny mortal! (At least until the dopamine wears off.)
Sidenote : I was thinking about buying a Haskell book, but I think I’ll read online first. Anyway, I’m having a bloody hard time searching for a place to read Haskell like I want to. Anyway, Currently reading through this. I’ll scour the internet for more stuff (and update here accordingly). Have fun guys!