Haskell is a pure functional programming language. We use the Haskell 2010 language specification, which was standardized in 2010. Let's try creating a simple program using basic development tools.
- Prerequisite: Haskell development environment setup
Creating the First Program in Haskell
$ mkdir first-program && cd $_
$ cabal init -n
Guessing dependencies...
Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating CHANGELOG.md...
Generating app/Main.hs...
Generating tmp.cabal...
Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.
$ cabal build
Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
- first-program-0.1.0.0 (lib) (first run)
- first-program-0.1.0.0 (exe:first-program) (first run)
Configuring library for first-program-0.1.0.0..
Preprocessing library for first-program-0.1.0.0..
Building library for first-program-0.1.0.0..
[1 of 1] Compiling MyLib ( src/MyLib.hs, /home/harry/Projects/codeandtips/code/haskell/first-program/dist-newstyle/build/x86_64-linux/ghc-8.10.7/first-program-0.1.0.0/build/MyLib.o, /home/harry/Projects/codeandtips/code/haskell/first-program/dist-newstyle/build/x86_64-linux/ghc-8.10.7/first-program-0.1.0.0/build/MyLib.dyn_o )
Configuring executable 'first-program' for first-program-0.1.0.0..
Preprocessing executable 'first-program' for first-program-0.1.0.0..
Building executable 'first-program' for first-program-0.1.0.0..
[1 of 1] Compiling Main ( app/Main.hs, /home/harry/Projects/codeandtips/code/haskell/first-program/dist-newstyle/build/x86_64-linux/ghc-8.10.7/first-program-0.1.0.0/x/first-program/build/first-program/first-program-tmp/Main.o )
Linking /home/harry/Projects/codeandtips/code/haskell/first-program/dist-newstyle/build/x86_64-linux/ghc-8.10.7/first-program-0.1.0.0/x/first-program/build/first-program/first-program ...
Hello, Haskell!
someFunc
$ cabal run
Up to date
Hello, Haskell!
someFunc
$ cabal build
Up to date
$ ./first-program
Hello, Haskell!
someFunc
C C++ C# Clojure Crystal D Dart Erlang F# Go Java Javascript Julia Kotlin Lua Python Rust Scala Swift Typescript