Haskell + emacs + Ghc-mod 4.0.1

Hello, I upgrade my emacs configuration with latest ghc-mod and all of sudden nothing works (again). When I try to load a .hs file from a project I got the first line highlighted with the error "cannot satisfy -package spec" and I cannot got type, info or doc from that file. Also I do not have anymore syntax errors highlighting I used to see. Any help greatly appreciated. I would also appreciate any pointer explaining how to setup and maintain a proper Haskell dev environment. Haskell is not the language I use at day work but I have been using it for years and every so often my emacs configuration is broken and I have a hard time getting it back to sane state. Thanks in advance Arnaud Here is my emacs configuration: ;; haskell coding (require 'haskell-mode) (require 'haskell-cabal) (autoload 'ghc-init "ghc" nil t) (add-hook 'haskell-mode-hook (lambda () (ghc-init))) (eval-after-load "haskell-mode" '(progn (define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-left) (define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right) (define-key haskell-mode-map (kbd "C-c v c") 'haskell-cabal-visit-file) (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-compile) (define-key haskell-mode-map (kbd "C-x C-d") nil) (setq haskell-font-lock-symbols t))) (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan) (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) (eval-after-load "which-func" '(add-to-list 'which-func-modes 'haskell-mode)) (eval-after-load "haskell-cabal" '(define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-compile)) Here is the output of ls -l ~/Library/Haskell/bin: lrwxr-xr-x 1 arnaud staff 45 Dec 27 22:36 HsColour -> ../ghc-7.6.3/lib/hscolour-1.20.3/bin/HsColour lrwxr-xr-x 1 arnaud staff 50 Dec 31 07:11 aeson-pretty -> ../ghc-7.6.3/lib/aeson-pretty-0.7/bin/aeson-pretty lrwxr-xr-x 1 arnaud staff 52 Dec 31 07:11 biblio2yaml -> ../ghc-7.6.3/lib/pandoc-citeproc-0.2/bin/biblio2yaml lrwxr-xr-x 1 arnaud staff 49 Jan 10 16:25 cabal -> ../ghc-7.6.3/lib/cabal-install-1.18.0.2/bin/cabal lrwxr-xr-x 1 arnaud staff 46 Jan 15 13:51 cabal-dev -> ../ghc-7.6.3/lib/cabal-dev-0.9.2/bin/cabal-dev lrwxr-xr-x 1 arnaud staff 39 Dec 27 22:36 cpphs -> ../ghc-7.6.3/lib/cpphs-1.17.1/bin/cpphs lrwxr-xr-x 1 arnaud staff 43 Dec 28 14:17 doctest -> ../ghc-7.6.3/lib/doctest-0.9.10/bin/doctest lrwxr-xr-x 1 arnaud staff 55 Jan 15 13:51 fake-ghc-cabal-dev -> ../ghc-7.6.3/lib/cabal-dev-0.9.2/bin/fake-ghc-cabal-dev lrwxr-xr-x 1 arnaud staff 62 Jan 26 11:15 ghc-events -> ../../../projects/data-scientist/.cabal-sandbox/bin/ghc-events lrwxr-xr-x 1 arnaud staff 42 Apr 3 15:04 ghc-mod -> ../ghc-7.6.3/lib/ghc-mod-4.0.1/bin/ghc-mod lrwxr-xr-x 1 arnaud staff 43 Apr 3 13:35 ghc-modi -> ../ghc-7.6.3/lib/ghc-mod-4.0.1/bin/ghc-modi lrwxr-xr-x 1 arnaud staff 55 Jan 15 13:51 ghc-pkg-6_8-compat -> ../ghc-7.6.3/lib/cabal-dev-0.9.2/bin/ghc-pkg-6_8-compat lrwxr-xr-x 1 arnaud staff 47 Dec 31 07:11 hakyll-init -> ../ghc-7.6.3/lib/hakyll-4.4.2.0/bin/hakyll-init lrwxr-xr-x 1 arnaud staff 45 Mar 31 13:57 hasktags -> ../ghc-7.6.3/lib/hasktags-0.68.7/bin/hasktags lrwxr-xr-x 1 arnaud staff 36 Mar 17 06:09 hell -> ../ghc-7.6.3/lib/hell-0.0.1/bin/hell lrwxr-xr-x 1 arnaud staff 39 Dec 27 22:36 hlint -> ../ghc-7.6.3/lib/hlint-1.8.55/bin/hlint lrwxr-xr-x 1 arnaud staff 47 Apr 3 15:07 hspec-discover -> ../ghc-7.6.3/lib/hspec-1.9.1/bin/hspec-discover lrwxr-xr-x 1 arnaud staff 58 Dec 31 07:11 make-pandoc-man-pages -> ../ghc-7.6.3/lib/pandoc-1.12.2.1/bin/make-pandoc-man-pages lrwxr-xr-x 1 arnaud staff 62 Jan 15 04:25 operational-TicTacToe -> ../ghc-7.6.3/lib/operational-0.2.2.1/bin/operational-TicTacToe lrwxr-xr-x 1 arnaud staff 43 Jan 15 05:14 pandoc -> ../ghc-7.6.3/lib/pandoc-1.12.2.1/bin/pandoc lrwxr-xr-x 1 arnaud staff 56 Dec 31 07:11 pandoc-citeproc -> ../ghc-7.6.3/lib/pandoc-citeproc-0.2/bin/pandoc-citeproc lrwxr-xr-x 1 arnaud staff 44 Dec 27 19:34 pdf2line -> ../ghc-7.6.3/lib/pdf2line-0.0.1/bin/pdf2line lrwxr-xr-x 1 arnaud staff 43 Dec 27 19:34 pdfdump -> ../ghc-7.6.3/lib/pdf2line-0.0.1/bin/pdfdump lrwxr-xr-x 1 arnaud staff 42 Jan 15 05:26 word2vec -> ../ghc-7.6.3/lib/word2vec-0.1/bin/word2vec lrwxr-xr-x 1 arnaud staff 43 Dec 31 07:11 yaml2json -> ../ghc-7.6.3/lib/yaml-0.8.5.2/bin/yaml2json lrwxr-xr-x 1 arnaud staff 34 Mar 13 08:58 yate -> ../ghc-7.6.3/lib/yate-0.1/bin/yate -- Arnaud Bailly FoldLabs Associate: http://foldlabs.com

I upgrade my emacs configuration with latest ghc-mod and all of sudden nothing works (again). When I try to load a .hs file from a project I got the first line highlighted with the error "cannot satisfy -package spec" and I cannot got type, info or doc from that file. Also I do not have anymore syntax errors highlighting I used to see.
As this message suggests, you need to install spec for testing. % cabal install spec # I don't know what the spec package is. A typo for hspec? This is because ghc-mod obtains dependency for executables, libraries *and* testing. In general, % cabal install --only-dependencies would help you. --Kazu

Thanks for your answer. hspec is installed actually:
$ cabal install --only-dependencies
Resolving dependencies...
All the requested packages are already installed:
Use --reinstall if you want to reinstall anyway.
And yes, ‘spec’ is a typo, the error message appears as a tooltip in emacs so I cannot copy/paste it as text.
I still do have the error however….
On 03 Apr 2014, at 23:30, Kazu Yamamoto (山本和彦)
I upgrade my emacs configuration with latest ghc-mod and all of sudden nothing works (again). When I try to load a .hs file from a project I got the first line highlighted with the error "cannot satisfy -package spec" and I cannot got type, info or doc from that file. Also I do not have anymore syntax errors highlighting I used to see.
As this message suggests, you need to install spec for testing.
% cabal install spec
# I don't know what the spec package is. A typo for hspec?
This is because ghc-mod obtains dependency for executables, libraries *and* testing.
In general, % cabal install --only-dependencies would help you.
--Kazu

OK, I forgot the —enable-tests flag to cabal install…
However, there seems to be some strange interactions I do not understand fully with the test section of cabal.
Here is the cabal file:
name: Thermometre
version: 0.1.0.0
synopsis: synopsis
-- description:
license: PublicDomain
license-file: LICENSE
author: Black
-- maintainer:
-- copyright:
-- category:
build-type: Simple
cabal-version: >= 1.8
library
hs-source-dirs:
src
exposed-modules:
Thermometre
build-depends:
base == 4.*
test-suite spec
type:
exitcode-stdio-1.0
ghc-options:
-Wall -Werror
hs-source-dirs:
test
main-is:
Spec.hs
build-depends:
base == 4.*
, Thermometre
, hspec >= 1.3
When I remove the test-suite section and open src/Thermometre.hs I got errors highlighting which is fine. C-c C-t does not give me types however ('Cannot guess type’ message).
When I leave the test-suite section then opening Thermometre.hs gives me a package error: ‘cannot satisfy -package Thermometre’ as there is a dependency from the tests to the main library.
How can I solve that?
Thanks
Arnaud
On 03 Apr 2014, at 23:30, Kazu Yamamoto (山本和彦)
I upgrade my emacs configuration with latest ghc-mod and all of sudden nothing works (again). When I try to load a .hs file from a project I got the first line highlighted with the error "cannot satisfy -package spec" and I cannot got type, info or doc from that file. Also I do not have anymore syntax errors highlighting I used to see.
As this message suggests, you need to install spec for testing.
% cabal install spec
# I don't know what the spec package is. A typo for hspec?
This is because ghc-mod obtains dependency for executables, libraries *and* testing.
In general, % cabal install --only-dependencies would help you.
--Kazu

OK, so now opening each file in emacs works correctly but when I try to
load the test file in haskell repl, it fails complaining it cannot find the
local package.
Here is my cabal file:
Name: tdd-qc
Version: 1.0
Build-type: Simple
Synopsis: This is a sample project
License: BSD3
License-file: LICENSE
Author: Arnaud Bailly
OK, I forgot the —enable-tests flag to cabal install…
However, there seems to be some strange interactions I do not understand fully with the test section of cabal. Here is the cabal file:
name: Thermometre version: 0.1.0.0 synopsis: synopsis -- description: license: PublicDomain license-file: LICENSE author: Black -- maintainer: -- copyright: -- category: build-type: Simple cabal-version: >= 1.8
library hs-source-dirs: src exposed-modules: Thermometre build-depends: base == 4.*
test-suite spec type: exitcode-stdio-1.0 ghc-options: -Wall -Werror hs-source-dirs: test main-is: Spec.hs build-depends: base == 4.* , Thermometre , hspec >= 1.3
When I remove the test-suite section and open src/Thermometre.hs I got errors highlighting which is fine. C-c C-t does not give me types however ('Cannot guess type’ message).
When I leave the test-suite section then opening Thermometre.hs gives me a package error: ‘cannot satisfy -package Thermometre’ as there is a dependency from the tests to the main library.
How can I solve that?
Thanks Arnaud
On 03 Apr 2014, at 23:30, Kazu Yamamoto (山本和彦)
wrote: I upgrade my emacs configuration with latest ghc-mod and all of sudden nothing works (again). When I try to load a .hs file from a project I got the first line highlighted with the error "cannot satisfy -package spec" and I cannot got type, info or doc from that file. Also I do not have anymore syntax errors highlighting I used to see.
As this message suggests, you need to install spec for testing.
% cabal install spec
# I don't know what the spec package is. A typo for hspec?
This is because ghc-mod obtains dependency for executables, libraries *and* testing.
In general, % cabal install --only-dependencies would help you.
--Kazu
participants (3)
-
Arnaud Bailly
-
Kazu Yamamoto
-
Konstantine Rybnikov