Atom haskell IDE autocompletion and typeinfo not working - haskell

I installed atom-haskell packages for syntax coloring, autocompletion and typeinfo but only syntax coloring is working. I installed every dependency (ghc-mod, ghc-modi and hlint). I added paths to dependencies in package haskell-ghc-mod. Everything should be working ... (Project is created via cabal).
EDIT: I dive deeper into into it and I realized that autocompletion depends on ghc-mod browse module command. And when I use this command, it returns nothing. It seems like a bug in ghc-mod for me. Any ideas what to do?
EDIT: this is strange. ghc-mod has working typeinfo, but in Atom, no typeinfo ...
EDIT: cabal version is 1.16.0.2
EDIT: ghc-mod version is 5.3.0.0
EDIT: Interesting. Only thing which is working is coloring ... the rest not works ... It's stupid, after more than 20 years of Haskell development, theres no "usable" IDE for it. I tryed emacs ... again, only coloring ...

Don't know if you are still using the ghc-mod version you said you are(version is 5.3.0.0), but in the docs (https://atom.io/packages/haskell-ghc-mod) it explicitly says the following:
Supported ghc-mod versions are from 4.1.0 to 5.2.1.2.
Try to rm and enforce this version.
According to stackage (https://www.stackage.org/package/ghc-mod) your version was published 14-Aug-2015 and the one supported by the atom plugin was published 8 months ago, 2014-12-31 v5.2.1.2.

Related

VSCode no intellisense in haskell extension for additional modules

Is there a way to make intellisense work for additional modules (anything outside the prelude) like Quicktest or Random in VS Code?
I am using:
VSCode: Version 1.55.0
the extension "Haskell v1.2.0" (with haskel-language-server)
ghci: GHCi, version 8.10.3: https://www.haskell.org/ghc/
stack: Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0
tried it direct on Windows10 and with WSL2 (Debian).
VSCode says:
Could not find module ‘Test.QuickCheck’
It is not a module in the current program, or in any known package.not found
So, no autocomplete etc..
I think the reason is that I've installed Quicktest via stack, and that stack uses its own "isolated" ghc. So I looked for a way to configure the VSCode extension to use the ghc of my stack environment, without success.
I've also tingled with haddock and cabal, without success.
Does anybody using VS-Code to code haskell and have autocomplete, documentation on mouse over, wingman, ...?
I was having this problem with some local modules. I was able to fix it by placing a hie.yaml file in the project's root directory and reloading VSCode. Admittedly I don't really know what it does. I generated it using implicit-hie which you can install with stack.

cabal doesn't seem to register installed packages [duplicate]

I'm a Haskell newcomer and have Haskell installed on my (Mac) machine; I'm trying to use newsynth (https://www.mathstat.dal.ca/~selinger/newsynth/, http://hackage.haskell.org/package/newsynth). In my terminal in the same place where I installed Haskell (home directory) I ran the command cabal install newsynth as suggested by the package authors. However, I can't figure out how to actually access anything from the package from the command line, let alone within a particular file.
In GHCi Prelude, I tried running commands of the form import Quantum and import Quantum.Synthesis.Diophantine but always get an error message. (e.g. in contrast, import Data.Complex works just fine.)
(I'm sure I'm missing something pretty obvious, but I only began with Haskell on Monday, and need to spin up some newsynth code by next week, which is why I'm not starting from the ground up.) Any advice on (1) how to run newsynth's functions from GHCi and (2) how to incorporate them into .hs files would be greatly appreciated. Thanks!
Edit: cabal --version returns
cabal-install version 3.2.0.0 (newline) compiled using version 3.2.0.0 of the Cabal library
Quoting a comment:
[cabal --version] returns: cabal-install version 3.2.0.0 (newline) compiled using version 3.2.0.0 of the Cabal library
It seems the installation instructions in the project page you linked to haven't been updated for cabal-install 3+ yet (in fairness, cabal-install 3 is relatively recent). In any case:
If all you want is running ghci and trying those modules out, with no strings attached, use cabal install --lib newsynth. That will make the newsynth package available in GHC's global environment (see the cabal install entry in the Cabal User Guide for further information).
Since you ultimately want to use the package in the code you'll have to write, though, my recommendation is using cabal init to create a new project for your code. Then, edit the .cabal file of the project to add newsynth to its build-depends section, and that's it: the package will be installed (if it isn't already) and made available in the context of your project the next time you do a cabal build to build the project, or a cabal repl to run GHCi in the context of your project. In that case, there is no need to use the cabal install command at all.

Override the cabal version of an LTS

I have a project that I want to compile with LTS 2, but I'm stuck trying to work around this well-known bug in OS X 10.11.
Can I somehow specify a newer version of Cabal to use with ghc-7.8.4? Note that the project only really compiles with GHC 7.8.*.
Edit:
Really meant Cabal, not cabal-install.
Edit 2:
Actually, the answer to this question doesn't really solve my concrete problem (compiling helium, which requires GHC <= 7.8.4), because the bug is not specific to Cabal, but rather to unix, which GHC < 7.10 depends upon.
I think the problem is related not just to Cabal library version (btw, stack doesn't use or need cabal-install), but also to GHC version. Stack's FAQ mentions an item about this error, but I think it didn't help for me and I just upgraded to 7.10.2 at the time.
Here's a recipe for installing ghc-7.8.4 into the directory of your choice:
Download the "bindist" from https://www.haskell.org/ghc/download_ghc_7_8_4#macosx_x86_64
Untar it into a scratch directory
Create the destination directory, e.g. $HOME/my-prefix.
In the scratch directory run:
$ ./configure --prefix=$HOME/my-prefix
$ make install
Now ghc may be found in $HOME/my-prefix/bin.
As noted in Michael Snoyman's comment, there is stack setup --upgrade-cabal to do just that. That's it for the answer to this question.
In my specific case (XY problem), for that to work I had to do the usual work-around for that El Capitano related bug, which is explained here. So I enabled rootless, ran the upgrade command and re-enabled rootless.
To no avail I'm afraid: The bug is specific to unix < 2.7.1.0, which GHC 7.8.4 also depends on. So even after upgrading cabal, I can't compile anything in lts-2 unless I disable rootless, which is pretty annoying.
Actually it's kinda depressing that the GHC folks decided not to file a new minor release with the updated unix package. This means that no realistic/recent OS X configuration can build anything which involves GHC < 7.10.

Synastic errors - Vim, Stack, Haskell development

I am using stack for my Haskell development and Syntastic for my error checking when editing in Vim. I have not installed the haskell-platform, instead, I use a stack build --install-ghc to get my environment up and running using the supported GHC, cabal and lts packages.
Normally, I use a cabal sandbox and syntastic works well with this. I see when I do a let g:syntastic_debug=3 in Vim, syntastic runs a cabal configure which checks if the project dependencies are installed and then goes ahead and does some hlint, hdevtools and ghc-mod magic to give me some warnings and/or error messages.
Now, here is my problem. Since my cabal setup (installed from stack) doesn't know about my dependencies installed at .stack-work or .stack (not sure), it complains that I am missing necessary packages and blows up when syntastic runs in my Vim instance.
Trying to run a stack exec -- cabal configure returns the following error:
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).
I haven't found out how to pass the --package-db option with the correct database. Nothing seems to work there.
So, the quetion - will successfully running a stack exec -- cabal configure, avoiding the GHC_PACKAGE_PATH issue get me to a working setup? Can anyone give me some direction here?
hdevtools works. See here: http://seanhess.github.io/2015/08/05/practical-haskell-editors.html
I'm planning on keeping that up to date as new tools come out (like stack-ide).
This blogpost gives a nice introduction as well. Things change quickly in the haskell world and ghc-mod seems to be working well with stack now. The setup from the post requires neovim though.
The setup from the post worked perfectly fine for me and found all dependencies within the current stack project.

Haskell on MAC LION

First of all, thank you for looking at this. I am a newbie to programming( I can program Java and Python)
I am gonna ask some really trivial questions.
How do i install the "extra " of Haskell on my mac? My situation is that i got ghci running, i am following the tutorial from my Terminal http://learnyouahaskell.com/introduction
I downloaded GHC
Xcode
Emacs(not working, more explanation below)
But i would like to have something like they use in their examples, a text editor that help me write in .hs and support the programming language. I tried to download Emacs but i couldn't find "haskell" as supported language, and i have no idea how to install it so it works together with my GHC. Also, i don't think the tutorial says a lot about Cabal. How do i access it? If i just go in and type "cabal install" or just "cabal" it just gives me "not in scope" as an answer.
Maybe i misunderstood cabal? it isn't something you "access" as such?
Thanks for checking my post out. I look forward to functional programming!( i am a mathematician :) )
Did you install ghc directly from http://www.haskell.org/ghc/ ? Usually it is better to install haskell platform as suggested in the tutorial. It includes cabal already.
If you used haskell platform, then try to find where cabal is installed and add the directory into your $PATH variable. I think you can fire a bug if platform installer for Mac doesn't install cabal in usual location.
(Note: AFAIK haskell platform installer is broken for new MacOS, it contains hardcoded path to xcode. But it is simple to find and fix)
Check out haskell mode for emacs. I don't use emacs, so the link is the only I can suggest, sorry.
If you have the Apple developer tools installed already, you can look at a package manager like e.g. homebrew (see at Link for installation). Then in a terminal you type
brew install ghc haskell-platform
and it will take care of everything, dependencies etc. You will get ghc, ghci, cabal, everything at once. It will put things in /usr/local/ so you might not even have to edit your $PATH ...
For editing, Aquamacs (download at http://aquamacs.org/) supports Haskell out of the box, and is very Mac-friendly.

Resources