简体   繁体   English

Windows 安装程序中的 Haskell

[英]Haskell on Windows Setup

Unfortunately I don't have access to a *nix box at work or at home.不幸的是,我无法在工作场所或家里使用 *nix 盒子。 The only way I can play with Haskell is on windows.我可以使用 Haskell 的唯一方法是在 Windows 上。 Anyone here using Haskell on Windows?这里有人在 Windows 上使用 Haskell 吗? What's your setup?你的设置是什么?

DISCLAIMER: What's below was valid in Oct, 2013. So there is a good chance it might get outdated soon. 免责声明:以下内容在2013年10月有效。因此很有可能很快就会过时。 Your edits and comments are welcome. 欢迎您进行编辑和评论。

This is what I have done in order to get Haskell set up on my Windows 7 x64 这就是我为了在Windows 7 x64上设置Haskell而做的

1. Install Haskell Platform 1.安装Haskell平台

Download and install the Haskell Platform from http://www.haskell.org/platform/windows.html http://www.haskell.org/platform/windows.html下载并安装Haskell平台

2. Install Sublime Text 3 2.安装Sublime Text 3

Download and install Sublime Text 3 from http://www.sublimetext.com/3 http://www.sublimetext.com/3下载并安装Sublime Text 3

3. Enable the Package manager in Sublime 3.在Sublime中启用包管理器

  1. Run Sublime 运行Sublime
  2. Open the console: View >> Show console 打开控制台: View >> Show console
  3. Paste the following code to the console and hit Enter (according to this ): 将以下代码粘贴到控制台并按Enter键(根据 ):

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 打开命令面板: Tools >> Command palette
  2. In the command palette popup type in: Package Control: Install Package 在命令面板中,弹出窗口输入: Package Control: Install Package
  3. Select the package: SublimeHaskell 选择包: SublimeHaskell

4. Install Haskell tools 4.安装Haskell工具

Cabal is the standard package manager for Haskell. Cabal是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 5.安装hdevtools

You can NOT install hdevtools on Windows by running: cabal instal hdevtools. 您无法通过运行以下命令在Windows上安装hdevtools: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) https://github.com/mvoidex/hdevtools下载适用于Windows的hdevtools源代码*(*目前不适用于GHC 7.10。 请参阅此fork以使用GHC 7.10及更高版本构建)

  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. 注意已安装hdevtools的路径(在控制台输出中)。 You will need this path when setting up the SublimeHaskell plugin in Sublime. 在Sublime中设置SublimeHaskell插件时,您将需要此路径。 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. 路径应如下所示: C:\\Users\\Aleksey Bykov\\AppData\\Roaming\\cabal\\bin其中Aleksey Bykov是当前用户的名称。

6. Setting up the SublimeHaskell plugin in Sublime: 6.在Sublime中设置SublimeHaskell插件:

  1. Start Sublime 启动Sublime
  2. Go Preferences >> Package settings >> SumblimeHaskell >> Settings - User 转到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 其中C:/Users/Aleksey Bykov/AppData/Roaming/cabal/bin/是那条路径(你在步骤5得到)hdevtools(所有其他工具都已安装)4。保存文件并重启Sublime

7. Hello world 你好世界

  1. Start Sublime 启动Sublime
  2. Create a new file and save it immediately as hello-world.hs 创建一个新文件并立即将其保存为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) 通过Tools >> Build x构建并运行2次(首先构建,第二次运行)

8. See also 8.另见

There is another great article: http://howistart.org/posts/haskell/1 还有一篇很棒的文章: http//howistart.org/posts/haskell/1

I've used Haskell on Windows, but only when forced to. 我在Windows上使用过Haskell,但只有在被迫时才使用。 Not because the combination Haskell+Windows is particularly bad, but just because I don't really like Windows. 不是因为Haskell + Windows的组合特别糟糕,而是因为我不喜欢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). 正如你所看到的,我试图获得一个尽可能类似于Unix的环境(不使用cygwin,因为我发现它完全令人困惑)。 Vim is my favourite editor. Vim是我最喜欢的编辑。 The reason for Visual Studio was that the C environment shipped with GHC doesn't cover all of Win32API. Visual Studio的原因是GHC附带的C环境并未涵盖Win32API的全部内容。 I used CMake to get a decent build environment. 我使用CMake来获得一个体面的构建环境。

Haskell平台现在或多或少是haskell的标准发行版,它有一个Windows安装程序。

GHC is a state-of-the-art, open source, compiler and interactive environment for the functional language Haskell. GHC是功能语言Haskell的最先进的开源编译器和交互式环境。

There is a Windows installer for GHC , but it for Version 6.4.2 . 有一个用于GHCWindows安装程序 ,但它适用于版本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. 版本6.10.1的Windows .exe (不是.msi安装程序)位于http://www.haskell.org/ghc/dist/6.10.1/目前尚不清楚当前版本(GHC 6.10.1)将提供Windows安装程序。

No one seems to have mentioned Atom yet, which I've been using for a few weeks now. 似乎没有人提到Atom ,我已经使用了几个星期了。 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. 它不像ST3那样稳定和成熟,但它看起来很有前途,并通过插件提供cabal(部分)和ghc-mod(良好)集成。

I based on Magnus solution. 我基于Magnus解决方案。 I have to state that I'm normally GNU/Linux user and I had to port low level packages ( like this one ). 我必须声明我通常是GNU / Linux用户,我不得不移植低级别的软件包( 比如这个 )。

I recall using hugs with some success a while ago. 我记得前一段时间使用拥抱取得了一些成功。 I was just playing around though. 我只是在玩耍。

Installing it on windows is much more difficult and painful that on a Mac (as it is with almost all dev software).在 Windows 上安装它比在 Mac 上更困难和痛苦(几乎所有的开发软件都是如此)。 That being said, here is the simplest way to set up a Haskell environment on Windows 10:话虽如此,以下是在 Windows 10 上设置 Haskell 环境的最简单方法:

Open Powershell as Aministrator (right click, and "Run as Administrator").以管理员身份打开 Powershell(右键单击,然后“以管理员身份运行”)。

1 In Powershell, check your execution policy as follows: 1 在 Powershell 中,按如下方式检查您的执行策略:

Get-ExecutionPolicy

2 If you get "Restricted", you need to change it. 2 如果您收到“受限”,则需要更改它。 Execute this command:执行这个命令:

Set-ExecutionPolicy Bypass -Scope Process

3 When you get a question prompt, type: 3 当您收到问题提示时,键入:

A

Hit Enter.按回车键。

4 Verify your policy again with Get-ExecutionPolicy. 4 使用 Get-ExecutionPolicy 再次验证您的策略。 Now your policy should be "Bypass".现在您的策略应该是“绕过”。

5 Double check that you have Chocolatey: 5 仔细检查您是否有巧克力:

choco

6 Install Haskell: 6 安装 Haskell:

choco install haskell-dev

It takes a while..需要一段时间..

7 Start coding in Haskell! 7 开始在 Haskell 中编码!

http://learnyouahaskell.com/starting-out http://learnyouahaskell.com/starting-out

How to install Haskell in windows10 :如何在 windows10 中安装 Haskell:

Step01: open windows powershell (run as administrator) and run the following command as instructed: Step01:打开windows powershell(以管理员身份运行),按照提示运行以下命令:

command 1 : command = Get-ExecutionPolicy, If it returns "Restricted" then run this command = Set-ExecutionPolicy AllSigned命令 1:命令 = Get-ExecutionPolicy,如果返回“Restricted”,则运行此命令 = Set-ExecutionPolicy AllSigned

command 2 : command = Set-ExecutionPolicy Bypass -Scope Process -Force;命令 2:命令 = Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; [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 ) iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))(注意:每次询问时输入“Y”并点击回车)

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步骤02:运行以下命令(在windows powershell中(以管理员身份运行)):command = choco install haskell-dev haskell-stack(注意:在运行此命令后,请输入“Y”并单击回车)关闭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) step03:验证您是否做对了一切:打开命令提示符并运行以下代码:command = ghc --version output should be = The Glorious Glasgow Haskell Compilation System, version 9.2.1(最小化命令提示符)

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)如何运行一个简单的代码并获得输出: step01:打开命令提示符并一一运行以下命令: cd \\ cls mkdir dev cd dev cls notepad hello.hs notepad 将打开,现在编写以下程序并保存: program : main = do print "我的第一个 Haskell 程序" 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=写下这个并保存步骤 02:运行之前最小化的程序打开命令提示符并运行以下命令:commands=

  1. ghc hello.hs ghc 你好.hs
  2. hello You should get the output as : My first Haskell program.你好 你应该得到这样的输出:我的第一个 Haskell 程序。

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.要在 vs 代码中使用相同的内容:执行上述步骤后,在 c 驱动器 dev 文件夹中打开(使用 vs 代码打开)hello.hs 文件,然后在扩展中安装 Haskell Syntax Highlighting 并在终端中运行相同的命令,选择命令提示符作为默认值而不是 windows powershell。 (note before you open the .hs in vs code make sure you delete every other file expect the hello.hs file) (注意在 vs 代码中打开 .hs 之前,请确保删除除 hello.hs 文件之外的所有其他文件)

您可以安装Sun的VirtualBox,并在其上安装Linux。

Or You could partition your hard-drive a duel boot between linux and windows :) 或者你可以分区你的硬盘驱动器在Linux和Windows之间的决斗启动:)

Doesn't answer your question, but it is an alternative. 不回答你的问题,但它是另一种选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM