michelou / haskell-examples

Playing with Haskell on Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Playing with Haskell on Windows

Haskell project 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 document PACKAGES.md.

Optionally one may also install the following software:

β˜› Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we defined C:\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 like awk, diff, file, grep, more, mv, rmdir, sed and wc).

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

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:

  1. setenv.bat - This batch command makes external tools such as cabal.exe, haddock.exe, ghc.exe and stack.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
    
  2. examples\*\build.bat - Each example can be built/run using the build 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 versionCabal version
9.6?
9.43.8 or later
8.x, 9.x3.4
8.x3.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)
VersionLLVMArchiveInstallationRemarks
9.6.39-12479 MB2.78 GBIncluded libraries
(new: bin\ghc-iserv-prof*.exe)
9.4.49-12479 MB2.78 GBIncluded libraries
(new: bin\ghc-iserv-prof*.exe)
9.2.2 a)10,11331 MB1.85 GBIncluded libraries
9.0.19236 MB2.64 GBIncluded libraries
8.10.79-12414 MB2.80 GBIncluded libraries
a) We observe a big size difference between version 9.2.2 and the others versions listed above.The difference is located in the 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).

mics/October 2023 β–²  

About

Playing with Haskell on Windows


Languages

Language:Haskell 98.9%Language:Yacc 0.8%Language:Logos 0.3%