Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean installation of Haskell onto a Windows 10 machine?

Tags:

haskell

I just started on Haskell and really love the language! Was looking for some installation help.

I just finished CIS194 and most of the excellent LYAH book. I am currently doing the fp-course recommended here: https://github.com/bitemyapp/fp-course

My issue is that i've done of my work on a mac os laptop up to this point, and now want to do a haskell installation on my windows desktop to work on my larger and more comfortable home setup; however i've struggled to find a method to do a "clean" installation. The haskell platform keeps recommending choclatey which doesn't seem to offer me a choice to change the download location. My issue is that i use a small SSD for my OS drive, and have a large 2TB secondary drive where i would like the installation to go instead.

My other point of confusion is that some people seem to vehemently recommend a stack installation instead of the haskell platform installation; whilst others say it doesn't matter. I'm a beginner so I doubt it matters to me but the haskell platform and choclatey were extremely frustrating as after I installed them, not only was I not able to find a beginner friendly way to change the installation directory, deleting packages/haskell entirely was extremely obtuse and hard to find resources for.

My concern is that over time, this will take a significant amount of space on my smaller system drive, forcing me to reformat again. I'm not sure if a Stack installation will be any better in this regard but I'm hoping for an installation that lets me choose exactly where all the files go.

Many posts outlined an uninstaller that should have come with the haskell platform, but it did not for me and was not shown in my add or remove programs so i had to resort to simply reformatting and am now looking for help before jumping back in (to hopefully avoid doing this again).

In summary, could I have help with doing an installation on a non-home drive, that is very easily removed, with clear knowledge of exactly where all the haskell files are, on a Windows 10 machine? Would really appreciate any help with this!

like image 926
ChairmanMeow Avatar asked Jun 22 '21 07:06

ChairmanMeow


People also ask

How do I install Haskell on Windows 10?

To set up Haskell environment on your Windows computer, go to their official website https://www.haskell.org/platform/windows.html and download the Installer according to your customizable architecture. Check out your system's architecture and download the corresponding setup file and run it.

Where is Haskell installed Windows?

On Windows, all of GHC's files are installed in a single directory. If you choose ``Custom'' from the list of install options, you will be given a choice about where this directory is; otherwise it will be installed in c:/ghc/ghc-version.

How do I know if I have Haskell installed?

If you have installed the Haskell Platform, open a terminal and type ghci (the name of the executable of the GHC interpreter) at the command prompt. Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. And you are presented with a prompt. The Haskell system now attentively awaits your input.

How do I run a Haskell file on Windows?

Open a command window and navigate to the directory where you want to keep your Haskell source files. Run Haskell by typing ghci or ghci MyFile. hs. (The "i" in "GHCi" stands for "interactive", as opposed to compiling and producing an executable file.)

How do I install Haskell Platform on a flash drive?

Haskell Platform's Windows installer (of which I'm the maintainer) has a "portable install" option that just extracts the files to the given location and does not touch the registry or any system settings. You can use it to install Haskell Platform to your flash drive, but you'll need to add GHC's location to the PATH manually.

How do I run Haskell on Windows?

Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. Moreover you are presented with a prompt. The Haskell system now attentively awaits your input.

What is Haskell programming environment?

Haskell Programming environment can be instlled on Windows 7,8,10. Haskell is a general purpose, purely functional programming language. This article will help you you to learn how to install Haskell in a video demonstration for your easiness.

How to prepare for a clean install of Windows 10?

When preparing to do a clean install of Windows 10, you only need a monitor, keyboard, mouse, and an internet connection. After the setup, you can reconnect the peripherals (one at a time) to make sure they don't cause any issues. How to create USB for clean install of Windows 10


2 Answers

The main space-hoggers of a GHC + cabal-install configuration are GHC itself and cabal-install's "store", the place where it caches compiled packages.

To fully control the installation directories:

  • Download the Windows binary distribution of GHC here. Decompress the folder (annoyingly, it's in .tar.xz format) and put the resulting /bin subfolder in your PATH environment variable.

  • Download the Windows binaries of cabal-install here. Decompress the program and put its location folder in your PATH environment variable

Create an initial Cabal configuration file with this command:

cabal --config-file=here-put-your-desired-conf-path user-config init

Create an environment variable CABAL_CONFIG whose value should be here-put-your-desired-conf-path.

(Remember to re-open the terminal every time you create/modify an environment variable. If you change the variables using the System Properties dialog, currently open terminals might not "get" the change.)

Edit the newly created here-put-your-desired-conf-path configuration file and edit the values for the remote-repo-cache:, store-dir:, world-file:, extra-prog-path:, build-summary: , installdir: and install-dirs user / prefix: fields, pointing them to new paths. Basically, change anything which points to places you don't want.


Edit: Actually, there's a better way than working with CABAL_CONFIG and having to manually edit the configuration file.

There's another environment variable called CABAL_DIR that points to some folder and, when specified, puts all cabal files below that folder. It also searches for the cabal config file there. According to the User Guide:

3.1.2.1. Configuration file discovery

If $CABAL_CONFIG is set use it,

otherwise if $CABAL_DIR is set use $CABAL_DIR/config

otherwise use getAppUserDirectory "cabal"

So, just after uncompressing cabal-install and putting its folder in the PATH, unset CABAL_CONFIG, define the CABAL_DIR environment variable, and point it to some existing folder that you want to use (and re-open any terminal so that they see the changes).

That should be enough, no need to explicitly create the config or modify it. All cabal files will be below CABAL_DIR.

like image 170
danidiaz Avatar answered Oct 23 '22 22:10

danidiaz


My advice, use stack for installing GHC and for project and dependency management. All Haskell's dependencies are under the stack folder (global) and .stack-work folder (per project), making it clean to remove and check for storage size: Just delete these folders and no trace of Haskell will reamain in your system. (Notice, that the path to the folders are system dependent, so check the documentation for windows installation)

The way stack helps you to keep dependencies/storage under control is by using snapshots. This is a fixed set of library version. For example:

  • lts-18.0 uses compiler version ghc-8.10.4. In the link you can see the version of each library.
  • As long as you use the same lts all along your global configuration and projects configuration, stack will reuse dependencies between projects, so you avoid downloading the same library with different version and different compilers too.

The problem with stack is that a miss-use of it, can lead to the storage problem you are afraid of. So, before using stack be sure you:

  1. Read the user guide. Most question asked in this site about stack are explicitly resolved in the user guide.

  2. Again, read the whole user guide... I'm serious about this. If you come from python-ish enviroment in which pip install solves your problems, you'll find a lot of troubles using stack due to project-oriented dependencies over global dependencies

  3. Be sure you understand what a snapshot (a.k.a. lts) is, and how to configure it, otherwise, you'll end up with many different version of the compiler installed in your computer (hence, tons of storage wasted).

  4. The differences between the stack.yaml and project.yaml.

  5. If you have a concrete question about stack come back here a post it. Please avoid generic questions like Can anyone explain stack?, it is prefered somthing specific and direct to the point. ex: what is the difference between lts-17 and lts-16?

like image 2
lsmor Avatar answered Oct 23 '22 23:10

lsmor