Using haskell in atom - ghc mod error - haskell

I have installed Haskell minimal installer on Windows 10. I have been using haskell by writiting small programs in Notepad++ and running then by ghci using ':l myfile.hs'
I have now installed the hackable 'ATOM' text editor and installed the atom-haskell core packages.
However, I get the error below
Haskell-ghc-mod: ghc-mod failed to launch. It is probably missing or misconfigured. ENOENT
Error was: Error
spawn ghc-mod ENOENT
Debug information:
{
"dir": "C:\\Users\\myfunnyusrname\\Desktop",
"err": {
"code": "ENOENT",
"errno": "ENOENT",
"syscall": "spawn ghc-mod",
"path": "ghc-mod",
"spawnargs": [
"version"
],
"cmd": "ghc-mod version"
},
"opts": {
"cwd": "C:\\Users\\myfunnyusrname\\Desktop",
"env": {
"Path": "C:\\Program Files\\Haskell\\bin;C:\\Program Files\\Haskell Platform\\8.0.2-a\\lib\\extralibs\\bin;C:\\Program Files\\Haskell Platform\\8.0.2-a\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files\\Java\\jdk1.8.0_121;C:\\Program Files\\Haskell Platform\\8.0.2-a\\mingw\\bin;C:\\Program Files\\nodejs\\;C:\\Ruby24-x64\\bin;C:\\Users\\myfunnyusrname\\Anaconda3;C:\\Users\\myfunnyusrname\\Anaconda3\\Scripts;C:\\Users\\myfunnyusrname\\Anaconda3\\Library\\bin;C:\\Users\\myfunnyusrname\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\myfunnyusrname\\AppData\\Roaming\\npm",
"PATH": "C:\\Program Files\\Haskell\\bin;C:\\Program Files\\Haskell Platform\\8.0.2-a\\lib\\extralibs\\bin;C:\\Program Files\\Haskell Platform\\8.0.2-a\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files\\Java\\jdk1.8.0_121;C:\\Program Files\\Haskell Platform\\8.0.2-a\\mingw\\bin;C:\\Program Files\\nodejs\\;C:\\Ruby24-x64\\bin;C:\\Users\\myfunnyusrname\\Anaconda3;C:\\Users\\myfunnyusrname\\Anaconda3\\Scripts;C:\\Users\\myfunnyusrname\\Anaconda3\\Library\\bin;C:\\Users\\myfunnyusrname\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\myfunnyusrname\\AppData\\Roaming\\npm"
},
"encoding": "utf8",
"maxBuffer": null
}
}
Environment (filtered):
{
"Path": "C:\\Program Files\\Haskell\\bin;C:\\Program Files\\Haskell Platform\\8.0.2-a\\lib\\extralibs\\bin;C:\\Program Files\\Haskell Platform\\8.0.2-a\\bin;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files\\Java\\jdk1.8.0_121;C:\\Program Files\\Haskell Platform\\8.0.2-a\\mingw\\bin;C:\\Program Files\\nodejs\\;C:\\Ruby24-x64\\bin;C:\\Users\\myfunnyusrname\\Anaconda3;C:\\Users\\myfunnyusrname\\Anaconda3\\Scripts;C:\\Users\\myfunnyusrname\\Anaconda3\\Library\\bin;C:\\Users\\myfunnyusrname\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\myfunnyusrname\\AppData\\Roaming\\npm"
}
Show Stack Trace
I understand that i am missing something BUT I do not know anything about PATH and variables.
If someone could please help me, I would be grateful to you
Note: I am using WINDOWS 10 laptop
Edit:
I have now installed ghc-mod (thanks to #Mark Seemann). But when i try 'ghc-mod' from gitbash I get:
K#ORUKO-PC MINGW64 ~
$ ghc-mod
bash: ghc-mod: command not found

Getting Haskell to work on Windows 10 in Atom is doable, but it does require a bit of fidgeting before you can get it to work.
ghc-mod
IIRC, ghc-mod isn't part of the GHC installation, so the first step you most likely need to take is to add it.
Cabal
If you're only using GHC (and not Stack), you can install it using Cabal:
$ cabal install ghc-mod
Stack
If you're just getting started with Haskell, then you probably want to stick with Cabal, but once you've gotten the hang of it and need to do slightly more complicated work, you should consider using Stack instead.
I usually have fairly good success with running
$ stack build ghc-mod
in my Stack project directory, but the Atom editor project has more detailed guidance here: https://github.com/atom-haskell/haskell-ghc-mod/wiki/Using-with-stack

Related

How to fix hdevtools - "GHC_PACKAGE_PATH is incompatible.." error

I'm a haskell beginner, I use the advent of code as learning examples.
When setting up for this year I reinstalled stack (on a new machine, however copied most dotfiles over) and was starting from my last years notes and was not able to get hdevtools working again.
I have set up a new project with stack new advent2019. In case it matters stack build on the "empty" project seems to take several minutes - seems much longer than last year. I install hdevtools with stack build hdevtools.
When I run stack exec hdevtools -- check src/Lib.hs I get following error:
Cabal error: hdevtools: Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible
with Cabal. Use the flag --package-db to specify a package database (it can be
used multiple times).
So far I tried:
I checked my shell and did an rg --no-ignore over my home directory to confirm GHC_PACKAGE_PATH is not set by me. Also over the project directory.
I was not able to figure out how to use the mentioned --package-db flag - putting it after hdevtools I get an unknown flag error, putting it to stack I get an invalid option.
stack exec --no-ghc-package-path hdevtools -- check src/Lib.hs - mentioned here
I deleted all possible related files: ~/.local/bin/hdevtools, everything from ~/.stack, all ~/.ghc*.
None helped with the error.
I suppose I overlooked something obvious - however can you help point it out?
For completeness:
on OS X, 10.15.1
stack --version: Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
stack ghc -- --version: The Glorious Glasgow Haskell Compilation System, version 8.6.5
stack path:
stack-root: /Users/me/.stack
project-root: /Users/me/Code/advent2019
config-location: /Users/me/Code/advent2019/stack.yaml
bin-path: /Users/me/.stack/snapshots/x86_64-osx/lts-14.16/8.6.5/bin:/Users/me/.stack/compiler-tools/x86_64-osx/ghc-8.6.5/bin:/Users/me/.stack/programs/x86_64-osx/ghc-8.6.5/bin:/usr/local/texlive/2018basic/bin/x86_64-darwin:/Users/me/.local/bin/:/Users/me/.gem/bin:/Users/me/.yarn/bin:/Users/me/Library/Python/3.7/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Library/TeX/texbin:.:/Applications/Wireshark.app/Contents/MacOS
programs: /Users/me/.stack/programs/x86_64-osx
compiler-exe: /Users/me/.stack/programs/x86_64-osx/ghc-8.6.5/bin/ghc
compiler-bin: /Users/me/.stack/programs/x86_64-osx/ghc-8.6.5/bin
compiler-tools-bin: /Users/me/.stack/compiler-tools/x86_64-osx/ghc-8.6.5/bin
local-bin: /Users/me/.local/bin
extra-include-dirs:
extra-library-dirs:
snapshot-pkg-db: /Users/me/.stack/snapshots/x86_64-osx/lts-14.16/8.6.5/pkgdb
local-pkg-db: /Users/me/Code/advent2019/.stack-work/install/x86_64-osx/lts-14.16/8.6.5/pkgdb
global-pkg-db: /Users/me/.stack/programs/x86_64-osx/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
ghc-package-path: /Users/me/Code/advent2019/.stack-work/install/x86_64-osx/lts-14.16/8.6.5/pkgdb:/Users/me/.stack/snapshots/x86_64-osx/lts-14.16/8.6.5/pkgdb:/Users/me/.stack/programs/x86_64-osx/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
snapshot-install-root: /Users/me/.stack/snapshots/x86_64-osx/lts-14.16/8.6.5
local-install-root: /Users/me/Code/advent2019/.stack-work/install/x86_64-osx/lts-14.16/8.6.5
snapshot-doc-root: /Users/me/.stack/snapshots/x86_64-osx/lts-14.16/8.6.5/doc
local-doc-root: /Users/me/Code/advent2019/.stack-work/install/x86_64-osx/lts-14.16/8.6.5/doc
dist-dir: .stack-work/dist/x86_64-osx/Cabal-2.4.0.1
/Users/me/Code/advent2019/.stack-work/install/x86_64-osx/lts-14.16/8.6.5/hpc
local-bin-path: /Users/me/.local/bin
ghc-paths: /Users/me/.stack/programs/x86_64-osx
The --no-ghc-package-path solution should have worked. However, you can just run hdevtools outside of Stack. On a Linux machine, if I run the following set of commands exactly:
$ stack new advent2019
$ cd advent2019
$ stack build
$ stack install hdevtools
$ hdevtools check src/Lib.hs
then hdevtools starts without error and runs in the background.
If your shell can't find hdevtools, it may be that ~/.local/bin is not in your path, so add it or try this instead:
$ ~/.local/bin/hdevtools check src/Lib.hs
Turns out I overlooked the .cabal directory in my purge. Though still had to also wipe .stack before installing hdevtools. Also had to build test separately so I would get dependency errors.
I don't think this is a solution for someone who uses haskell productively. Reminds me of my Windows 95 days where support told you to format and reinstall for every issue.

ghc-modi and cabal version

(Haskell newbie here)
I'm trying to configure HaskForce plugin into IntelliJ IDEA, configured "ghc-mod" with "legacy-interactive" in "GHC Modi" Flags. The root problem seems to be related to cabal version, although when I try autocompleting on any Haskell symbol, I get this:
ghc-modi error
Unable to parse problems from ghc-modi: cabal-helper-wrapper.exe: ghc: readCreateProcess: does not exist (No such file or directory)
ghc-mod: readCreateProcess: C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist" (exit 1): failed
When I run this last command (C:\ACME\projects\htest\.cabal-sandbox\cabal-helper-0.5.3.0-553kah86RQN6BuDX6XLBiX\cabal-helper-wrapper.exe "C:\\ACME\\projects\\htest" "C:\\ACME\\projects\\htest\\dist"), it tries to install cabal 1.18:
cabal-helper-wrapper.exe: Installing Cabal version 1.18.1.3 failed.
I already have cabal, of version 1.22 (installed via Haskell Platform v7.10.2-a, released recently in August).
Is there any way to work around this issue (i.e. still use ghc-mod / ghc-modi)?
Updated Haskforce plugin (0.3-beta24) seems to work correctly with following ghc-mod:
ghc-mod version 5.4.0.0 compiled by GHC 7.10.2

Cannot install accelerate-cuda in Haskell

I am on a linux box and trying to experiment with Haskell's Accelerate library but having problems installing it. I have successfully installed the accelerate package but there seems to be a dependency problem, which I have detailed below.
cabal: Error: some packages failed to install:
accelerate-cuda-0.14.0.0 depends on haskell-src-exts-1.14.0.1 which failed to
install.
cuda-0.5.1.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-exts-1.14.0.1 failed during the configure step. The exception was:
ExitFailure 1
haskell-src-meta-0.6.0.5 depends on haskell-src-exts-1.14.0.1 which failed to
install.
language-c-quote-0.7.6 depends on haskell-src-exts-1.14.0.1 which failed to
install.
I searched SO and noticed someone else had a similiar issue installed the cuda package, and was resolved by adding the cabal bin path to the PATH; I tried this but it didn't solve this problem.
Please could someone help as I really keen to play with this fantastic library.
I wanted to check accelerate-examples and play with them and I also didn't have CUDA GPU (AMD only) and that's how I eventually installed accelerate-examples with stack:
git clone https://github.com/AccelerateHS/accelerate-examples
cd accelerate-examples
#choose version:
ln stack-8.6.yaml stack.yaml
#build without CUDA targeting:
stack build --flag accelerate-examples:-llvm-ptx --flag accelerate-fft:-llvm-ptx
Installation will build all the examples and print the info regarding where they was put.
Might also need to specify GHC libs path with something like: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.stack/programs/x86_64-linux/ghc-8.6.5/lib/ghc-8.6.5/rts/
Also checked that accelerate installs as well the same way but even without specifying any flags (I guess because it doesn't build any programs yet?), but examples are what's fun :)
P.S. You can move llvm-ptx flags to stack.yaml config: change # flags: {} line to:
flags:
accelerate-fft:
llvm-ptx: false
accelerate-examples:
llvm-ptx: false

Is there way to specify compiler flags (e.g., preprocessor macro definitions) on the node-gyp command line?

I'm trying to integrate a Node.js addon into an existing build system based on CMake. The addon build requires a large number of preprocessor macro definitions and library dependencies that are available in the CMake context. I would like to be able to pass these into node-gyp when it is invoked by CMake. Unfortunately, I have not been able to find a simple way to do so.
I've tried using the approach used for plain old gyp like this:
node-gyp configure -d -DPOSIX=1
but the -D option doesn't seem to be passed on by node-gyp. Looking at the source for node-gyp, this isn't entirely surprising. Is there a straightforward, direct way to do this, or am I stuck with generating the entries in binding.gyp programmatically, pulling in this information from the environment or something else along those lines?
Use "defines".
{
"targets": [
{
"target_name": "MyAddon",
"sources": [ "File1.cpp", "File2.cpp" ],
"libraries": [ "MyNeeded.lib" ],
"defines": [ "_UNICODE", "UNICODE" ]
}
]
}
This adds the defines to the in your config.gypi when running node-gyp configure
I'm not sure why you see a downside to using the cflags setting in binding.gyp - but I just make something similar work by setting the flags using .bashrc
export CFLAGS='-m32'
export CXXFLAGS='-m32'
export LDFLAGS='-m3'

node-gyp configure to release mode

Hi I am trying to compile a node_modules as Release mode, but I could not successfully configure as Release mode.
I ran node-gyp configure; the configure.gypi generated
# Do not edit. File was generated by node-gyp's "configure" step {
"target_defaults": {
"cflags": [],
**"default_configuration": "Debug",**
"defines": [],
"include_dirs": [],
"libraries": [] },
I tried with -DBUILDTYPE=Release and BUILDTYPE=Release but not successfully
Default should be Release.
Try node-gyp configure --release

Resources