Windows IDE for Haskell - windows

I need to setup a simple and compelling dev environment for small proyects written in Haskell in Windows machines for freshmen.
I have tried several ways to integrate Haskell into VSCode in Windows with no success.
I had a nice setup a few years ago, but I´m finding problems with dependencies recreating that environment:
Editor: Atom
Global binaries build using: stack with ghc-mod hlint stylish-haskell
Atom plugins: language-haskell, ide-haskell, ide-haskell-repl, haskell-ghc-mod
It seems that the "cool" way right now is Language Server Protocol + VScode. ghc-mod seems not to be mantained anymore, Intero has reached EOL, HEI is merging with another project... Having a stable and updated dev environment looks like a moving target.
So, the question is: does anyone have reproducible step-by-step instructions for having VSCode working with Haskell in Windows?
I will test any suggestion in a fresh Windows 10 64bits VM and report the results.
Note: VSCode + Docker container is not an option. Most of the student´s machines have 4GB RAM.
Thanks in advance.

There's a tool called ghcid (not to be confused with ghcide) that, while nowhere near a full-blown IDE, is pretty robust and provides some niceties like re-compiling on save and showing compile errors. It doesn't support go-to-definition though. It has a VSCode plugin.
Here's a possible way of setting up things in Windows:
Download the GHC 8.8.3 binaries for Windows from here.
Download the cabal-install 3.0.0.0 binaries for Windows from here.
Decompress them in some folder.
Add entries to your PATH environment variable so that it has access to the /bin folder of the GHC installation and to the folder containing the cabal executable.
Open a Powershell console.
Run cabal udpate
Run cabal install --install-method=copy --installdir=somefolder ghcid to install the ghcid executable, where "somefolder" is the destination folder. (If the installation fails, try running the command from a Git Bash or Cygwin terminal as a workaround.) Put the destination folder in PATH.
Open (or restart) VSCode and install the "Haskell Syntax Highlighting" and haskell-ghcid plugins.
Go to an example cabal project, use the Ctrl-Shift-P shortcut, and execute the Start ghcid action. The ghcid terminal will appear.
Example of a ghcid session showing an error:
The haskell-ghcid plugin can read a .ghcid file in the project root containing flags that should be passed to the ghcid command.
Extra instructions to set up code formatting:
Install the ormulu formatter by running cabal install ormolu --install-method=copy --installdir=somefolder. Again, make sure that the destination folder in in PATH.
Open (or restart) VSCode and install the ormulu plugin.
Now the "Format Document" and "Format Selection" actions in VSCode will use ormulu.
Another way of installing GHC and getting to ghcid and ormulu could be by using the stack tool, which handles GHC installation by itself.

Related

How to add Cargo to PATH required for pywinpty when deploying to Heroku?

I am getting the following error on Windows:
Cargo, the Rust package manager, is not installed or is not on PATH.
remote: This package requires Rust and Cargo to compile extensions.
I've installed Rust and cargo is in the path, but the problem persists. Does anybody know why this is happening?
Error message is the same as in this post.
Heroku's stack runs on Ubuntu. Cargo is required by pywinpty but that's a library required for communicating with Windows processes. You may need it for your local environment but you don't need it for Heroku. You should try removing pywinpty from your requirements.txt when you deploy to Heroku.
If you want a temporary solution
Open a command line prompt (cmd) and execute
path
that will show you the actual, current path. Inspect it to see whether the necessary directories are really absent. If they are, execute
path=%path%;directory you want to add;other directory you want to add
The path will be available in the command prompt for as long as it's open. If they are present, reboot the computer, the addition to the path may have been delayed after installation.
The permanent solution
For Win10 but I guess instructions are not very different for other flavors.
Open System properties, find Environment Variables. In the dialog that pops up you will see System Variables, among which you will see Path. Select it, click edit and add the directories you need via the New button. Close all popup boxes and reboot (always a good idea when Windows is stubborn ;-) )

How to install GnuPlot on windows?

A Unix (mac/Linux) user who has been forced to work on a windows machine here :)
I have scripted loads of work in GnuPlot and don't want to switch to other programs at this moment. I would appreciate it if you could help me know how to install GnuPlot On windows (more specifically windows 10). questions:
I know there are two options according to this page, Cygwin and MinGW. which one is better?
I have MinGW installed and I know I need to install one of the options from this page but I don't know which one(s)! and how.
I have searched the internet but it seems most of the search results are for compiling. I don't want to go through compiling and all the hassle.
I tried installing the binary from this link, and when I try to run the program this is the error I get:
Unable to execute file:
C:\Program Files\gnuplot\bin\wgnuplot.exe
CreatProcess failed; Code267.
The directory name is invalid.
I would appreciate it if you could give me a very simple stepwise installation (1 2 3 ...), preferably with visuals, and instructions.
P.S. A nice way to install Free, Libre, and Open Source Software (FLOSS) on Windows and keep them updated, is to use package managers like Chocolatey. There are GnuPlot chocolatey packages here. Just install choco as instructed here. Then use choco install Gnuplot to have the software installed.
You don't have to install MinGW or Cygwin. Actually packages compiled in MinGW are compatible with Windows. Just download the binary of gnuplot from Their repo and you are good to go.
Additional points:
When installing, check which terminals you want to set up; also
check if you want the installer to add the PATH variable to your
system. Also, create a desktop shortcut.
After installation, you should see the desktop shortcut. Clicking on it should open a terminal-based gnuplot (which hopefully you are familiar with).
Please note that I have used the x11 terminal (you can get this working by installing xming). There are other options such as windows and qt terminals, but I am not an expert on using these.
You should have Administrator rights on this machine.
Right click on MinGW, Run as Administrator, install - should be OK.
Good luck!
BR, Alex
You can try
$~ scoop install gnuplot
Installing 'Gnuplot' (5.4.5) [64bit] from main bucket
gp545-win64-mingw.7z (37.7 MB) [=======================================] 100%
Checking hash of gp545-win64-mingw.7z ... ok.
Extracting gp545-win64-mingw.7z ... done.
Linking ~\scoop\apps\Gnuplot\current => ~\scoop\apps\Gnuplot\5.4.5
Creating shim for 'gnuplot'.
Creating shortcut for GNUPlot (wgnuplot.exe)
'Gnuplot' (5.4.5) was installed successfully!

pycharm swig how to? [windows]

I would require some guidance in regards to installing a module/package in pycharm (free edition). I have to mention that i have not worked with this IDE yet and wanted to try it out on a little project containing smartcards.
When i try to install "pyscard" i get the error that boils down to
error: command 'swig.exe' failed: No such file or directory
People say just install SWIG, which i guessed already ^^.
The issue i have is that i actually have no idea how to... and none of the pages i found has really enlightended me on this issue.
I downloaded the zip "swigwin-3.0.12" but i am at a loss what to do with it now. EDIT: According to the SWIG page this is an already compiled version and i have to somehow make pycharm recognize that the folder it is in contains the swig.exe it requires.
EDIT2: Adding the folder containing the swig.exe to the PATH variable also did not work ... which i thought would be the issue
EDIT3+Answer:
Ok the link in the comments from "wp78de" was correct my problem was that pycharm/pc restart were needed for it to catch the added PATH variable to the swig.exe (for pycharm that is)
Any advice is appriciated.
Envoirment:
Windows 8.1 Pro 64-bit
Pycharm 2017.2.4
Python 3.6
Basically, you just have to add the directory that contains the swig executable the PATH environment variable. You can do it via CMD or the Windows UI.
If you have added swig to your path, you should be able to call it in the command prompt from any directory: open "cmd", and type swig --help" on that prompt.
A restart of PyCharm (or whatever your IDE is) and Windows might be required.

using stackage on windows

I am trying to use stackage on windows. I cloned the git repo, ran cabal install --only-dependencies, cabal configure, cabal build. Everything works
then dist\build\Stackage\stackage.exe select
Loading Haskell Platform
Loading package database
Narrowing package database
Printing build plan to build-plan.log
Checking for bad versions
authenticate-oauth-1.4.0.8 (FP Complete <michael#fpcomplete.com> #yesodweb) cannot use:
- RSA-2.0 -- ==1.2.*
threepenny-gui-0.4.1.0 (FP Complete <michael#fpcomplete.com>) cannot use:
- aeson-0.7.0.2 -- ==0.6.*
stackage.exe: Conflicting build plan, exiting
the readme mention *.sh scripts like ./patching/scripts/create-tarballs.sh. I tried but failed to run them with cygwin. Are they important?
How can I use stackage on windows?
edit I was able to run the ./patching/scripts/create-tarballs.sh script using msys. But now the error message is:
Loading Haskell Platform
Loading package database
stackage.exe: Missing cabal file "MFlow-0.3.3/MFlow.cabal" in tarball: "patching/tarballs\\MFlow-0.3.3.tar.gz"
I checked the archive: the cabal file is inside.
Windows users are not recommended to install stackage by Haskell Platform installer due to some limitation:
On Windows, it does not provide a complete environment (missing MSYS).
By placing a large number of packages in the global package database, Haskell Platform installations are more easily corrupted.
The choice of package versions conflicts with the needs of many commonly used packages.
Some of the package versions included with the platform have known and severe bugs, and cannot be reliably upgraded.
As for solution to overcome, uninstall the Haskell platform first, then install minghc for windows by the following link: https://github.com/fpco/minghc#readme
Open command prompt run cabal update and cabal install alex happy.
Finally, install stackage.
Update 2015
A new tool has been developed by Commercial Haskell group for project development -- Stack, it can be install along with the latest Haskell Platform (7.10.2).
Features include:
Installing GHC automatically, in an isolated location.
Installing packages needed for your project.
Building your project.
Testing your project.
Benchmarking your project.
I have tried it for haskell web project, it works smoothly.

How to install pkg config in windows?

I am trying to do it, but all I can get is some source code that I don't know how to do deal with I downloaded from http://pkgconfig.freedesktop.org/releases/.
This is a step-by-step procedure to get pkg-config working on Windows, based on my experience, using the info from Oliver Zendel's comment.
I assume here that MinGW was installed to C:\MinGW. There were multiple versions of the packages available, and in each case I just downloaded the latest version.
go to http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
download the file pkg-config_0.26-1_win32.zip
extract the file bin/pkg-config.exe to C:\MinGW\bin
download the file gettext-runtime_0.18.1.1-2_win32.zip
extract the file bin/intl.dll to C:\MinGW\bin
go to http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28
download the file glib_2.28.8-1_win32.zip
extract the file bin/libglib-2.0-0.dll to C:\MinGW\bin
Now CMake will be able to use pkg-config if it is configured to use MinGW.
Get the precompiled binaries from http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
Download pkg-config and its depend libraries :
pkg-config_0.26-1_win32.zip
glib_2.28.8-1_win32.zip
gettext-runtime_0.18.1.1-2_win32.zip
A alternative without glib dependency is pkg-config-lite.
Extract pkg-config.exe from the archive and put it in your path.
Nowdays this package is available using chocolatey, then it could be installed with
choco install pkgconfiglite
I did this by installing Cygwin64 from this link https://www.cygwin.com/
Then - View Full, Search gcc and scroll down to find pkg-config.
Click on icon to select latest version.
This worked for me well.
I would like to extend the answer of #dzintars about the Cygwin version of pkg-config in that focus how should one use it properly with CMake, because I see various comments about CMake in this topic.
I have experienced many troubles with CMake + Cygwin's pkg-config and I want to share my experience how to avoid them.
1. The symlink C:/Cygwin64/bin/pkg-config -> pkgconf.exe does not work in Windows console.
It is not a native Windows .lnk symlink and it won't be callable in Windows console cmd.exe even if you add ".;" to your %PATHEXT% (see https://www.mail-archive.com/cygwin#cygwin.com/msg104088.html).
It won't work from CMake, because CMake calls pkg-config with the method execute_process() (FindPkgConfig.cmake) which opens a new cmd.exe.
Solution: Add -DPKG_CONFIG_EXECUTABLE=C:/Cygwin64/bin/pkgconf.exe to the CMake command line (or set it in CMakeLists.txt).
2. Cygwin's pkg-config recognizes only Cygwin paths in PKG_CONFIG_PATH (no Windows paths).
For example, on my system the .pc files are located in C:\Cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\lib\pkgconfig. The following three paths are valid, but only path C works in PKG_CONFIG_PATH:
A) c:/Cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig -
does not work.
B) /c/cygdrive/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig -
does not work.
C) /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig - works.
Solution: add .pc files location always as a Cygwin path into PKG_CONFIG_PATH.
3) CMake converts forward slashes to backslashes in PKG_CONFIG_PATH on Cygwin.
It happens due to the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21629. It prevents using the workaround described in [2].
Solution: manually update the function _pkg_set_path_internal() in the file C:/Program Files/CMake/share/cmake-3.x/Modules/FindPkgConfig.cmake. Comment/remove the line:
file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
4) CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH have no effect on pkg-config in Cygwin.
Reason: the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21775.
Solution: Use only PKG_CONFIG_PATH as an environment variable if you run CMake builds on Cygwin. Forget about CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH.
Install mingw64 from https://sourceforge.net/projects/mingw-w64/. Avoid program files/(x86) folder for installation. Ex. c:/mingw-w64
Download pkg-config__win64.zip from here
Extract above zip file and copy paste all the files from pkg-config/bin folder to mingw-w64. In my case its 'C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin'
Now set path = C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
taddaaa you are done.
If you find any security issue then follow steps as well
Search for windows defender security center in system
Navigate to apps & browser control> Exploit protection settings> Program setting> Click on '+add program customize'
Select add program by name
Enter program name: pkgconf.exe
OK
Now check all the settings and set it all the settings to off and apply.
Thats DONE!
Another place where you can get more updated binaries can be found at Fedora Build System site. Direct link to mingw-pkg-config package is: http://koji.fedoraproject.org/koji/buildinfo?buildID=354619
for w64-based computers you have to install mingw64. If pkg-config.exe is missing then, you can refer to http://ftp.acc.umu.se/pub/gnome/binaries/win64/dependencies/
Unzip and copy/merge pkg-config.exe into your C:\mingw-w64 installation, eg. into on my pc into C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
In 2022 VS Code works with CMake & pkgconfig out of the box (add pkgconf && vcpkg-pkgconfig-get-modules to your vcpkg.json)
From: https://github.com/JoinMarket-Org/joinmarket/wiki/Installing-JoinMarket-on-Windows
This guide describes how to install JoinMarket and its dependencies (python, libsodium, secp256k1) on Windows.
Some or all of this may or may not work for all versions of Windows. Reports appreciated. It is not claimed to be in any way comprehensive. Verification of downloads are your own responsibility.
Install JoinMarket - go to https://github.com/JoinMarket-Org/joinmarket/releases and download the most recent release. Unzip it into any location you choose.
You will need to install MinGW from here or go to their website. After a few introductory screens, you will be shown a windows with some optional components that you have to choose; this basic setup is sufficient:
From "Basic Setup" in the left menu:
mingw-developer-toolkit
mingw32-base
mingw32-gcc-g++
msys-base
Once you have chosen these, choose "Update" from the main menu first item. These components will be installed into C:\MinGW\bin. Once that is complete, you should have this dll: libgcc_s_dw2-1.dll in that folder C:\MinGW\bin, along with a lot of other files; I'm mentioning this file explicitly, since it's needed specifically for libsecp256k1 to operate in this setup.
Next, you must make sure C:\MinGW\bin is added to your PATH variable. Here's one guide to how to do that; you must append ;C:\MinGW\bin to the end of the path before continuing.
Install Python from https://www.python.org/ftp/python/2.7.11/python-2.7.11.msi. Run the executable. Choose to install the feature Add python.exe to Path (it's the last option in the installer, off by default - switch it on) on local hard drive during installation; Python should then be installed in C:\Python27 (EXTRA NOTE: the most recent 2.7 installation linked here seems to install pip automatically, which is very useful for step 4)
Check that Python runs. Open a new command prompt as administrator by typing cmd.exe into the Start menu and pressing Ctrl+Shift+Enter. Type python and you should see something like:
Python 2.7.11 (default....
....
>>>
Exit the Python console with exit() or by pressing Ctrl+C. Now, make sure your version of pip is up to date: run the command: python -m pip install --upgrade pip.
Go to the directory C:\Python27\Lib\distutils and add a new file, called distutils.cfg. Inside it, put:
[build]
compiler=mingw32
Close and save the file.
Next, you need to install the dll for libnacl. First go to https://download.libsodium.org/libsodium/releases/ and choose the file libsodium-1.0.4-msvc.zip to download. Unzip anywhere, and then copy the file libsodium.dll from the directory \Win32\Release\v120\dynamic (do not use v140), and paste it into root joinmarket directory (the same directory where README.md lives). Then you need to address the Visual C++ 2013 runtime dependency. Do so by going to www.microsoft.com/en-us/download/details.aspx?id=40784 and clicking Download. Choose x86 even on a 64-bit system, and run the executable.
Note that after doing this, you must run pip install -r requirements-windows.txt from the Joinmarket root directory (where the README.md file is) and should not get an error message (this will install/check the python packages libnacl and secp256k1(-transient)).

Resources