Using Hlint via the command prompt works for me, but I have problem trying to perform the GHCi integration.
http://community.haskell.org/~ndm/darcs/hlint/hlint.htm says that "the script is at hlint.ghci [link], and a copy is installed locally in the data directory. To use, add the contents to your GHCi startup file.".
C:\Users\X\AppData\Roaming\cabal\hlint-1.8.23 contains this hlint.ghci file.
Now I want to find the GHCi startup file. I am using Windows 7 and according to http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-dot-files.html the ghci.conf file should be in a folder like .../appdata/ghc. But my ghc folder (C:\Users\X\AppData\Roaming\ghc) only contains a ghci_history file.
So I copied the hlint.ghci file to my ghc folder and renamed it to ghci.conf.
Starting now WinGHCi it crashes, if I start GHCi it says:
interactive>:10:91:
lexical error in string/character literal at character '\n'
interactive>:4:105:
lexical error in string/character literal at character '\n'
What am I doing wrong?
Has the problem something to do with the missing GHCi startup file?
The problem was a bug with the hlint.ghci file shipped with HLint version 1.8.23 and below. HLint 1.8.24 is now available which fixes the problem, or use the online copy of hlint.ghci with an older version of HLint.
This bug was tracked by http://code.google.com/p/ndmitchell/issues/detail?id=531 and I originally said I "will probably fix it later today".
Related
I am trying to setup haskell-linter for vs-code.
I have installed hlint using cabal. Location of hlint
~/.cabal/bin/hlint
I have also added the above path in setting.json of VSCode.
"haskell.hlint.executablePath": "~/.cabal/bin/hlint"
But still getting the following error in vs-code:
Cannot hlint the haskell file. The hlint program was not found. Use the 'haskell.hlint.executablePath' setting to configure the location of 'hlint'
I am using Mac os.
Can someone help ?
Edit 1 :
Also tried adding the full path but still no success.
"haskell.hlint.executablePath": "/Users/ujjwal/.cabal/bin/hlint"
This seems to work for me. (Mac Intel)
On macOS, opening my terminal and typing: which hlint
=> /Users/admin/.local/bin/hlint
If the command can't find hlint, you might want to find out where it's installed on your machine and add it to your PATH.
Then went to vscode settings (cmd + ,) -> extensions -> haskell-linter, then pasted /Users/admin/.local/bin/hlint as the "Executable Path". You will need to paste your own result from which hlint obviously.
I have a package with bunch of *.c and *.cpp files, listed inside c-sources field of *.cabal file. I need to include it inside a project with IHaskell and some other packages. Everything works fine, and builds without a problem. stack exec ghci works fine and I can import modules and execute any code. stack ghci though throws some weird errors, like this:
In file included from <command-line>:10:0:
/...blabla.../.stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/autogen/cabal_macros.h:157:0:
note: this is the location of the previous definition
#define CURRENT_PACKAGE_KEY "blabla"
^
And stack ghci inside my package complains about symbols exported from its C code. Another weird thing is that symbols depend on the order of exposed-modules in the configuration, so the error goes away if I put my *.hs module on top of others, but if I have two *.hs files importing from the same *.c file, it won't work! stack exec jupyter -- console --kernel haskell starts, but immediately throws unknown symbol error if I try to run some code from my package, always the same though.
I have a docker image based on fpco/stack-build, which just installs jupyter and other necessary stuff. I use lts-3.0 snapshot, if it's somehow relevant.
What is going on?
There have been a lot of improvements made recently to stack ghci, which is still mostly a work in progress. I'd recommend testing out stack master, and if the problem still exists opening a Github issue.
I was trying to to install Haskell Platform 2014 2.0 but I can't really understand what am I supposed to do to make it work and there seems to be no useful documentation on the site.
I downloaded the binary dist from the site, unpacked it, launched the 'activate-hs' script and got this:
Haskell set to:
GHC /home/riccardo/usr/local/haskell/ghc-7.8.3-x86_64
Haddocks file:///home/riccardo/usr/local/haskell/ghc-7.8.3-x86_64/doc/frames.html
Other doc file:///home/riccardo/usr/local/haskell/ghc-7.8.3-x86_64/share/doc/ghc/html/index.html
Symlinks for command line tools (ghc, cabal, etc..) added to:
/usr/local/bin
Even running in --verbose tells me nothing more about what's going on, it just returns a list of all the files.
What should I do?
EDIT:
riccardo#eos:~$ whereis ghc
ghc: /usr/local/bin/ghc
If I go to /usr/local/bin the symlinks are there and they point to the respective files in /home/riccardo/usr/local/haskell/ghc-7.8.3-x86_64/bin, but in the property window it says they are broken, what does this mean?
Also, if I get into home/riccardo/usr/local/haskell/ghc-7.8.3-x86_64/bin and try to launch the scripts directly from there, it still won't work:
riccardo#eos:~/usr/local/haskell/ghc-7.8.3-x86_64/bin$ ./ghci-7.8.3
./ghci-7.8.3: line 2: /usr/local/haskell/ghc-7.8.3-x86_64/bin/ghc-7.8.3: File o directory non esistente
File o directory non esistente = file or directory does not exist
For posterity, if you're installing the generic-linux binary package as this appears to be describing, you cannot just run activate-hs. Rather you run install-haskell-platform.sh which puts everything in the proper place. Following that, you can use the installed activate-hs in the future if you want to swap between different versions...
I have working Eclipse (Kepler Service Release 2) + EclipseFP (2.6.0) + Haskell Platform under Windows 8.1 x64.
In one moment after some cabal install, EclipseFP stopped working and showing me:
The program ghc version >=6.4 is required but it could not be found.
I have:
Uninstalled Haskell Platform
Deleted C:\Users\myuser\AppData\Roaming\cabal*
Deleted C:\Program Files (x86)\Haskell*
Install Haskell Platform 2013.2
Run Eclipse with my Haskell workspace
Try to build my project
It gave me this error about ghc and cannot build it.
EclipseFP configuration found all Haskell Helper executables. It found Cabal 1.16.0.2 and GHC 7.6.3 already. From command-line GHC and cabal are found and are working. "cabal build" is working on the project from command-line, too.
This message doesn't say almost anything! If I could see the path it is searching for GHC or where it get this path from...
EDIT:
Message from buildwrapper:
"C:\Users\home\AppData\Roaming\cabal\bin\buildwrapper.exe synchronize --force=false --tempfolder=.dist-buildwrapper --cabalpath=C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin\cabal.exe --cabalfile=D:\Project\haskell2\SomeGL\SomeGL.cabal --cabalflags= --logcabal=true
configuring because setup_config not present
"C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin\cabal.exe" "configure" "--verbose=1" "--user" "--enable-tests" "--enable-benchmarks" "--builddir=D:\Project\haskell2\SomeGL.dist-buildwrapper\dist"
cabal.exe: The program ghc version >=6.4 is required but it could not be found."
Calling exactly the last line from cmd.exe (as normal non-admin user) everything is working fine:
"C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin\cabal.exe" "configure" "--verbose=1" "--user" "--enable-tests" "--enable-benchmarks" "--builddir=D:\Project\haskell2\SomeGL\.dist-buildwrapper\dist"
EDIT:
To find the potential path environement that is used I tried to run GHCi console inside Eclipse and tried:
import System.Environment
x <- getEnvironment
filter (\ (a,_) -> a == "Path") x
and got something that is starting with:
[("Path","C:\Program Files (x86)\Haskell\bin;C:\Program Files
(x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin;C:\Program
Files (x86)\Haskell Platform\2013.2.0.0\bin;...")]
First folder is invalid, but Haskell Platform is valid and working.
Another thing I found. One of times I have run "Build All" command there was run Process in Eclipse with GHC and the path was:
Running executable C:\Program Files (x86)\Haskell
Platform\2013.2.0.0\bin\ghc.exe
I went to see this process details and it is run from the same user that is currently Eclipse run with. And the path is correct, but I still got the error:
The program ghc version >=6.4 is required but it could not be found.
Running from command-line still it is working. The program has errors, but only in command-line I see them.
Could someone help with finding this problem?
EDIT:
I found some interesting issue. Running "Build All" command is executing this command:
C:\Users\myuser\AppData\Roaming\cabal\bin\buildwrapper.exe synchronize
--force=false --tempfolder=.dist-buildwrapper --cabalpath=C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin\cabal.exe
--cabalfile=D:\haskell\SomeGL\SomeGL.cabal --cabalflags= --logcabal=true
Which run from command-line gives an error. The problem is that there are no quotes around cabalpath, because it has spaces in it. When I run it that way from command-line it works:
C:\Users\myuser\AppData\Roaming\cabal\bin\buildwrapper.exe synchronize --force=false --tempfolder=.dist-buildwrapper --cabalpath="C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin\cabal.exe" --cabalfile=D:\haskell\SomeGL\SomeGL.cabal --cabalflags= --logcabal=true
I think that all "--cabalfile" parameters should have quotes, because paths could have spaces in them. I still don't know if this is the problem under Eclipse.
I found the problem!
It is that EclipseFP 2.6.0 is using upper case "PATH" variable, but my Windows 8.1 use "Path" and programatically some kind it is possible to have valid two variables "PATH" and "Path" when executing BuildWrapper and Cabal. So something is messing up.
Workaround for this problem is if you rename from Control Panel | System | Environment variables for both User and System from "Path" to "PATH".
I hope this could be fixed in EclipseFP so it could in future work in any case.
Building your project means that under the scenes, cabal build is launched. If you activate the debugging mode in the Haskell helper executable preference page (show BuildWrapper responses), you should see the exact cabal build command being sent. It could be that the path used in Eclipse is different than the path used in the command line, check you eclipse shortcuts. EclipseFP can find the executables because it searches also in some well known folders on windows.
You can also take the current dev version of EclipseFP from github. It should now pass --with-ghc to cabal invocations to make sure the path detected in Eclipse is the one used.
I am extremely new to haskell and I have been searching all over the web but I haven't been able to solve my problem. I downloaded the Quipper package but I have not been able to get haskell to recognize where all of the modules and files are and how to properly link everything.
I have downloaded all of the files and programs and installed them properly, I just dont know how to get haskell to recognize the quipper libraries and templates. Evey time I try:
:load And_gate.hs or some other file.
I get:
Could not find module "Quipper" or its respective modules it requires.
I don't think it is an error or anything, I think it is just my lack of knowledge on how haskell works.
I'm using windows 7.
So I emailed Peter Selinger, one of the professors who created Quipper.
The only thing I need to do extra was inside MSYS:
ghci -iC:/quipper -iC:/quipper/quipper
This complies everything correctly and the files run properly.
Here is his email to me:
Dear -----,
thanks for writing. Let me see if I can help.
Are you following the instructions in the README file? Under "Building
the various algorithms and programs", the instruction is to run
"make". This would build all of the tests in the "tests" directory
automatically.
Next, to compile a Quipper program, you should use the "quipper"
script that is located in quipper/scripts. It works just like "ghc",
except that it automatically includes the correct directories for
Quipper's files in the search path. On Windows, you would be using
"quipper.bat".
Quipper is not really meant to be run interactively, i.e., from ghci.
However, if you do need to run Quipper interactively, I recommend
using the "quipperi" script, also in quipper/scripts. This too would
set the load paths correctly. In Windows, use "quipperi.bat".
Finally, if you need to include Quipper stuff from ghci, but for some
reason can't or don't want to use the quipperi script, you need to
specify those directories with the "-i" option, for example
ghci -iC:/quipper -iC:/quipper/quipper
It could be that in Windows, you need to use "\" instead of "/", but I
am not sure if this is necessary.
I hope this helps, -- Peter
When compiling and exe with ghc just make sure you include the commands:
-iC:/quipper -iC:/quipper/quipper.
If you use the quipper script as suggested by Professor Selinger, inside of MSYS do the following:
Navigate to the folder in which all of the Quipper files are held, this was my case:
cd C:/quipper/quipper/scripts
Then type quipper and your file's location in MSYS to compile an exe like so:
quipper C:/quipper/tests/And_gate.hs
The file will compile and should print updates like so:
[1 of 22] Compiling Libraries.Typeable (......
[2 of 22] Compiling Libraries.Tuple (......
and so on.
The exe (in this case And_gate.exe) will be inside the folder it was compiled from (C:/quipper/tests). You'll need to move it to a folder that contains the acroread.bat which comes in quipper/scripts for it to work properly.
For some reason, this code isn't packaged as a standard Haskell package. It if were, installing it would be fairly simple. As it is, the instructions in the README file look awful (especially under Windows, where it looks like you need MSYS to run the makefile).
Your problem might be as simple as telling GHCi which folder to look in to find the files; you can do that using the :cd command. Since you're on Windows, I'd suggest trying WinGHCi, which should allow you to browse to the right folder using the GUI.
If it isn't that simple... really, as a Haskell beginner, you're probably going to struggle to get this working. The documentation looks pretty minimal.
If you red both README and INSTALLING.windows and did everything as well, then you should add a path to Quipper's script folder to environment variable. Here is the path:
quipper-*/quipper/scripts/
where quipper-* is a <distribution name>-<version>.
There are two important scripts in that folder. The first one is quipper.bat which runs a ghc compiler to run Quipper's modules. The second one is quipperi.bat which is a ghci analogue for Quipper.
Now, when you added a path to variable, you can run And_gate.hs in Quipper's interpreter as follows:
quipperi And_gate.hs