user20155
user20155

Reputation: 1044

Haskell on Windows Setup

Unfortunately I don't have access to a *nix box at work or at home. The only way I can play with Haskell is on windows. Anyone here using Haskell on Windows? What's your setup?

Upvotes: 30

Views: 21924

Answers (11)

HaskellElephant
HaskellElephant

Reputation: 9891

UPDATE as of 2024: Haskell platform is now deprecated

Original answer:

Haskell Platform is now more or less the standard distribution of haskell, and it has a windows installer.

Upvotes: 10

Swagath
Swagath

Reputation: 11

How to install Haskell in windows10 :

Step01: open windows powershell (run as administrator) and run the following command as instructed:

command 1 : command = Get-ExecutionPolicy, If it returns "Restricted" then run this command = Set-ExecutionPolicy AllSigned

command 2 : command = Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) (note: type "Y" whenever it asks and click enter )

step02:run the following command(in windows powershell (run as administrator)): command = choco install haskell-dev haskell-stack (note: type "Y" whenever it asks and click enter ) after running this command close the powershell

step03: verification if you did everything right: open command prompt and run the following code: command = ghc --version output should be = The Glorious Glasgow Haskell Compilation System, version 9.2.1 (minimize the command prompt)

how to run a simple code and get output : step01: open command prompt and run the following commands one by one: cd \ cls mkdir dev cd dev cls notepad hello.hs notepad will open and now write the following program and save it : program: main = do print "My first Haskell program" name <- getLine print ("Hello, " ++name)

write this and save step 02 : to run the program open command prompt that was minimized before and run the following commands: commands=

  1. ghc hello.hs
  2. hello You should get the output as : My first Haskell program.

To use the same in vs code: after you do the above steps open(open with vs code) hello.hs file in c drive dev folder and then in extentions install Haskell Syntax Highlighting and run the same commands in terminal choose command prompt as default rather than windows powershell. (note before you open the .hs in vs code make sure you delete every other file expect the hello.hs file)

Upvotes: 1

Dennis Kozevnikoff
Dennis Kozevnikoff

Reputation: 2277

Installing it on windows is much more difficult and painful that on a Mac (as it is with almost all dev software). That being said, here is the simplest way to set up a Haskell environment on Windows 10:

Open Powershell as Aministrator (right click, and "Run as Administrator").

1 In Powershell, check your execution policy as follows:

Get-ExecutionPolicy

2 If you get "Restricted", you need to change it. Execute this command:

Set-ExecutionPolicy Bypass -Scope Process

3 When you get a question prompt, type:

A

Hit Enter.

4 Verify your policy again with Get-ExecutionPolicy. Now your policy should be "Bypass".

5 Double check that you have Chocolatey:

choco

6 Install Haskell:

choco install haskell-dev

It takes a while..

7 Start coding in Haskell!

http://learnyouahaskell.com/starting-out

Upvotes: 0

Trident D&#39;Gao
Trident D&#39;Gao

Reputation: 19680

DISCLAIMER: What's below was valid in Oct, 2013. So there is a good chance it might get outdated soon. Your edits and comments are welcome.

This is what I have done in order to get Haskell set up on my Windows 7 x64

1. Install Haskell Platform

Download and install the Haskell Platform from http://www.haskell.org/platform/windows.html

2. Install Sublime Text 3

Download and install Sublime Text 3 from http://www.sublimetext.com/3

3. Enable the Package manager in Sublime

  1. Run Sublime
  2. Open the console: View >> Show console
  3. Paste the following code to the console and hit Enter (according to this):

import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

  1. Open the command palette: Tools >> Command palette
  2. In the command palette popup type in: Package Control: Install Package
  3. Select the package: SublimeHaskell

4. Install Haskell tools

Cabal is the standard package manager for Haskell. What you need to do is:

  1. Start a console with administrative permissions
  2. Run:

    cabal install cabal-install
    cabal update
    cabal install aeson
    cabal install haskell-src-exts
    cabal install ghc-mod
    cabal install cmdargs
    cabal install haddock
    

5. Install hdevtools

You can NOT install hdevtools on Windows by running: cabal instal hdevtools. What you need to do instead is:

  1. Download the source code of hdevtools for Windows from https://github.com/mvoidex/hdevtools* (* Currently does not work with GHC 7.10. See this fork for building with GHC 7.10 and above)

  2. Unpack it to some folder

  3. Go to that folder and run:

    runhaskell Setup.hs configure --user
    runhaskell Setup.hs build
    runhaskell Setup.hs install
    
  4. Watch for the path (in the console output) where the hdevtools have been installed. You will need this path when setting up the SublimeHaskell plugin in Sublime. The path should look something like this: C:\Users\Aleksey Bykov\AppData\Roaming\cabal\bin where Aleksey Bykov is the name of the current user.

6. Setting up the SublimeHaskell plugin in Sublime:

  1. Start Sublime
  2. Go Preferences >> Package settings >> SumblimeHaskell >> Settings - User
  3. Make sure you configuration looks like:

    {
        "add_to_PATH":
        [
            "C:/Users/Aleksey Bykov/AppData/Roaming/cabal/bin/"
        ],
        "enable_hdevtools": true
    }
    

where C:/Users/Aleksey Bykov/AppData/Roaming/cabal/bin/ is that path (you got at step 5) where hdevtools (all all other toolls have been installed) 4. Save the file and restart Sublime

7. Hello world

  1. Start Sublime
  2. Create a new file and save it immediately as hello-world.hs
  3. Put the following code there:

    main::IO()
    main = putStrLn "Hello world!"
    
  4. Build and run by going Tools >> Build x 2 times (first it builds, second it runs)

8. See also

There is another great article: http://howistart.org/posts/haskell/1

Upvotes: 40

SwiftsNamesake
SwiftsNamesake

Reputation: 1578

No one seems to have mentioned Atom yet, which I've been using for a few weeks now. It's not quite as stable and mature as ST3 yet, but it looks promising and offers cabal (partial) and ghc-mod (good) integration via plugins.

Upvotes: 1

Maja Piechotka
Maja Piechotka

Reputation: 7216

I based on Magnus solution. I have to state that I'm normally GNU/Linux user and I had to port low level packages (like this one).

Upvotes: 0

SomeDude
SomeDude

Reputation: 1

You could install Sun's VirtualBox, and install Linux on it.

Upvotes: -1

Magnus
Magnus

Reputation: 4714

I've used Haskell on Windows, but only when forced to. Not because the combination Haskell+Windows is particularly bad, but just because I don't really like Windows.

My setup was basically the following:

As you can see I was trying to get an environment that was as similar to Unix as possible (without using cygwin, because I find it utterly confusing). Vim is my favourite editor. The reason for Visual Studio was that the C environment shipped with GHC doesn't cover all of Win32API. I used CMake to get a decent build environment.

Upvotes: 13

gimel
gimel

Reputation: 86344

GHC is a state-of-the-art, open source, compiler and interactive environment for the functional language Haskell.

There is a Windows installer for GHC, but it for Version 6.4.2 .

A Windows .exe (not an .msi installer) for version 6.10.1 is at http://www.haskell.org/ghc/dist/6.10.1/ It is not clear when the current (GHC 6.10.1) version will offer a Windows installer.

Upvotes: 1

Sekhat
Sekhat

Reputation: 4479

Or You could partition your hard-drive a duel boot between linux and windows :)

Doesn't answer your question, but it is an alternative.

Upvotes: -1

1800 INFORMATION
1800 INFORMATION

Reputation: 135245

I recall using hugs with some success a while ago. I was just playing around though.

Upvotes: 0

Related Questions