My record with studying Learn You a Haskell for Great Good!; will be a Haskell Tutorial in future
- Introduction
- Starting Out
- Types and Typeclasses
- Syntax in Functions
- Recursion
- Higer Order Functions
- Module
- Making Our Own Types and Typeclasses
- Input and Output
- Functionally Solving Problems
- Functiors, Applicative Functors and Monoids
- A Fistful of Monads
- For a Few Monads More
- Zippers
Install GHCup
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
Create a new file named hello.hs
.Write the following in it:
main :: IO ()
main = do
putStrLn "Hello, everybody!"
putStrLn ("Please look at my favorite odd numbers: " ++ show (filter odd [10..20]))
You can now compile ith with ghc
to produce an executable .
$ ghc hello.hs
Here the hello.o
is exactly the same as C's object files; the hello.hi
file is an interface file
; you could say that the .hi
file is the equivalent of C's header files.
$ ls
hello hello.hi hello.hs hello.o
Let's run the executable file
$ ./hello
Hello, everybody!
Please look at my favorite odd numbers: [11,13,15,17,19]
$ ghci hello.hs
GHCi, version 9.2.5: https://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( hello.hs, interpreted )
Ok, one module loaded.
ghci> main
Hello, everybody!
Please look at my favorite odd numbers: [11,13,15,17,19]
ghci> :quit
Leaving GHCi.