Playing with Haskell on Windows
This repository gathers Haskell examples coming from various websites and books. It also includes several build scripts (batch files, Maven scripts) for experimenting with Haskell on a Windows machine. |
Ada, Akka, C++, Dart, Deno, Docker, Flix, Golang, GraalVM, Kafka, Kotlin, LLVM, Node.js, Rust, Scala 3, Spark, Spring, TruffleSqueak and WiX Toolset are other topics we are continuously monitoring.
Project dependencies
This project relies on the following external software for the Microsoft Windows platform:
β Haskell packages
We present the installed Haskell packages in documentPACKAGES.md
.
Optionally one may also install the following software:
- Apache Maven 3.9 (requires Java 8 or newer) (release notes)
- Haskell 9.6 (release notes)
- Stack 2.11 (changelog)
- Temurin OpenJDK 11 (release notes, for Maven)
β Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we definedC:\opt\
as the installation directory for optional software tools (in reference to the/opt/
directory on Unix).
For instance our development environment looks as follows (October 2023) 2:
C:\opt\apache-maven\ ( 10 MB) C:\opt\ghc-8.10.7\ (2.5 GB) C:\opt\ghc-9.4.4\ (2.6 GB) C:\opt\Git\ (358 MB) C:\opt\jdk-temurin-11.0.20_8\ (181 MB) C:\opt\stack-2.11.1\ ( 74 MB)
π Git for Windows provides a BASH emulation used to run
git
from the command line (as well as over 250 Unix commands likeawk
,diff
,file
,grep
,more
,mv
,rmdir
,sed
andwc
).
Directory structure β΄
This project is organized as follows:
docs\ examples\{README.md, HelloWorld, ..} parconc-examples\{README.md, ..} PACKAGES.md README.md RESOURCES.md REPL.md setenv.bat
where
- directory
docs\
contains Haskell related papers/articles. - directory
examples\
contains Haskell examples grabbed from various websites (see fileexamples\README.md
). - directory
parconc-examples
contains Haskell examples from Simon Marlow's book (see fileparconc-examples\README.md
). - file
PACKAGES.md
presents the Haskell packages our projects depend on. - file
README.md
is the Markdown document for this page. - file
REPL.md
presents GHCi usage examples. - file
RESOURCES.md
gathers Haskell related informations. - file
setenv.bat
is the batch command for setting up our environment.
We also define a virtual drive β e.g. drive H:
β in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).
π We use the Windows external command
subst
to create virtual drives; for instance:> subst H: %USERPROFILE%\workspace\haskell-examples
In the next section we give a brief description of the batch files present in this project.
Batch commands
We distinguish different sets of batch commands:
-
setenv.bat
- This batch command makes external tools such ascabal.exe
,haddock.exe
,ghc.exe
andstack.exe
directly available from the command prompt (see section Project dependencies).> setenv help Usage: setenv { <option> | <subcommand> } Options: -debug print commands executed by this script -verbose print environment settings Subcommands: help print this help message
-
examples\*\build.bat
- Each example can be built/run using thebuild
command.> build Usage: build { <option> | <subcommand> } Options: -debug print commands executed by this script -timer print total execution time -verbose print progress messages Subcommands: clean delete generated files compile generate program executable doc generate HTML documentation help print this help message run execute the generated program
Usage examples β΄
setenv.bat
We execute command setenv
once to setup our development environment; it makes external tools such as cabal.exe
, haddock.exe
, ghc.exe
and stack.exe
directly available from the command prompt:
> setenv Tool versions: cabal 3.8.1.0, ghc version 8.10.7, stack 2.11.1, haddock 2.24.2 hlint v3.5, hpack 0.35.1, htfpp 0.14.0.6, ormolu 0.7.0.0 java 11.0.20, mvn 3.9.4, git 2.42.0.windows.1, diff 3.10 > where hlint hpack stack %APPDATA%\Cabal\bin\hlint.exe %APPDATA%\Cabal\bin\hpack.exe C:\opt\stack-2.11.1\stack.exe
Command setenv -verbose
also displays the tool paths and defined variables:
> setenv -verbose Tool versions: cabal 3.8.1.0, ghc version 8.10.7, stack 2.11.1, haddock 2.24.2 hlint v3.5, hpack 0.35.1, htfpp 0.14.0.6, ormolu 0.7.0.0 java 11.0.20, mvn 3.9.4, git 2.42.0.windows.1, diff 3.10 Tool paths: %APPDATA%\cabal\bin\cabal.exe C:\opt\ghc-8.10.7\bin\ghc.exe C:\opt\stack-2.11.1\stack.exe C:\opt\ghc-8.10.7\bin\haddock.exe %APPDATA%\Cabal\bin\hlint.exe %APPDATA%\Cabal\bin\hpack.exe %APPDATA%\Cabal\bin\htfpp.exe %APPDATA%\Cabal\bin\ormolu.exe C:\opt\jdk-temurin-11.0.20_8\bin\java.exe C:\opt\apache-maven\bin\mvn.cmd C:\opt\Git\bin\git.exe C:\opt\Git\mingw64\bin\git.exe C:\opt\Git\usr\bin\diff.exe Environment variables: "CABAL_DIR=%APPDATA%\cabal" "GHC_HOME=C:\opt\ghc-8.10.7" "JAVA_HOME=C:\opt\jdk-temurin-11.0.20_8" "MAVEN_HOME=C:\opt\apache-maven" "STACK_HOME=C:\opt\stack-2.11.1"
Footnotes β΄
[1] Cabal compatibility β©
-
GHC version Cabal version 9.6 ? 9.4 3.8 or later 8.x, 9.x 3.4 8.x 3.2
[2] Downloads β©
- In our case we downloaded the following installation files (see section 1):
-
apache-maven-3.9.4-bin.zip ( 10 MB) cabal-install-3.8.1.0-x86_64-unknown-mingw32.zip ( 5 MB) ghc-8.10.7-x86_64-unknown-mingw32.tar.xz (414 MB) ghc-9.6.1-x86_64-unknown-mingw32.tar.xz (471 MB) OpenJDK11U-jdk_x64_windows_hotspot_11.0.20_8.zip ( 99 MB) PortableGit-2.42.0.2-64-bit.7z.exe ( 41 MB) stack-2.11.1-windows-x86_64.zip ( 15 MB)
-
Version LLVM Archive Installation Remarks 9.6.3 9-12 479 MB 2.78 GB Included libraries
(new:bin\ghc-iserv-prof*.exe
)9.4.4 9-12 479 MB 2.78 GB Included libraries
(new:bin\ghc-iserv-prof*.exe
)9.2.2 a) 10,11 331 MB 1.85 GB Included libraries 9.0.1 9 236 MB 2.64 GB Included libraries 8.10.7 9-12 414 MB 2.80 GB Included libraries lib\x8_64-windows-ghc-9.x.x\
directory, e.g.array-0.5.4.0\
with 1.7 MB versus 4.3 MB due to the absence/presence of the profiling object files (.p_o
extension).