[Haskell-cafe] Correctly setting up emacs + ghc-mod

Arnaud Bailly arnaud.oqube at gmail.com
Mon Apr 21 07:30:06 UTC 2014


I tried it but to no avail. Still got the same error. I removed ghc-init from my config, just in case, and still have the problem

Will post on haskell-mode ML…

Arnaud
On 20 Apr 2014, at 16:28, Zsolt Dollenstein <zsol.zsol at gmail.com> wrote:

> Have you tried M-x haskell-process-unignore?
> 
> 
> On Sun, Apr 20, 2014 at 10:20 AM, Arnaud Bailly <arnaud.oqube at gmail.com> wrote:
> This is what I have in my cabal file:
> 
> 	library
>     hs-source-dirs: ., fay-shared
>     exposed-modules: Application
>                      Foundation
>  
> but I keep getting same error when loading a file that depends on the fay-shared directory (please not that command-line building with cabal runs fine so this is definitely an issue with my emacs settings).
> 
> Here is the output I got in haskell interpreter when loading a file that depends on fay-shared/SharedTypes.hs:
> 
> GHCi is ignoring: /home/vagrant/yesod-splittest/.ghci (run M-x haskell-process-unignore)                                                                                                                    
> The next big Haskell project is about to start!
> If I break, you can:
>   1. Restart:           M-x haskell-process-restart
>   2. Configure logging: C-h v haskell-process-log (useful for debugging)
>   3. General config:    M-x customize-mode
>   4. Hide these tips:   C-h v haskell-process-show-debug-tips
> Changed directory: /home/vagrant/yesod-splittest/
> Import.hs:18:18-28: Could not find module `SharedTypes' …                                                                                                                                                   
>     Use -v to see a list of the files searched for.                                                                                                                                                         
> Compilation failed.                                                                                                                                                                                         
> Import.hs:18:18-28: Could not find module `SharedTypes' …                                                                                                                                                   
>     Use -v to see a list of the files searched for.                                                                                                                                                         
> Compilation failed.                                                                                                                                                                                         
> λ> 
> 
> Thanks
> Arnaud
> 
>  
> On 19 Apr 2014, at 13:05, Andras Slemmer <0slemi0 at gmail.com> wrote:
> 
>> If you're using several source directories then simply specify them in your .cabal with hs-source-dirs. So for example if you have a library in src/lib and a test-suite in src/test and your tests use your lib then you'd have something like this in your .cabal
>> 
>> library
>>   exposed-modules: Lib
>>   hs-source-dirs: src/lib
>> 
>> test-suite sometest
>>   type:           exitcode-stdio-1.0
>>   main-is:        Test.hs
>>   hs-source-dirs: src/test src/lib
>> 
>> 
>> 
>> On 18 April 2014 16:20, Arnaud Bailly <arnaud.oqube at gmail.com> wrote:
>> Hello,
>> 
>> I am struggling to get my emacs settings right for doing significant Haskell development, eg. something more involved than a bunch of source files in a single directory. The issue I am running in currently is that when trying to load files in the interpreter, most source paths are missing which means loading inevitably fails. This is especially annoying with tests: To get things working correctly I need to explicitly add in the console
>> 
>> > :set -iwhere/my/src/are
>> 
>> Is there any configuration I should be aware of in my cabal files or .emacs file that would correctly set the source roots? Am I missing something?
>> 
>> Here is my .emacs configuration. Thanks for any help.
>> 
>> ;; haskell coding                                                                                                                                                                                          
>> (require 'auto-complete)
>> (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
>>      (setq haskell-stylish-on-save t)
>>      (setq haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans"
>>                "--with-ghc=ghci-ng"))
>> 
>>      (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)
>> 
>>      ;; Do this to get a variable in scope                                                                                                                                                                 
>>      (auto-complete-mode)
>> 
>>      ;; from http://pastebin.com/tJyyEBAS                                                                                                                                                                  
>>      (ac-define-source ghc-mod
>>        '((depends ghc)
>>          (candidates . (ghc-select-completion-symbol))
>>          (symbol . "s")
>>          (cache)))
>> 
>>      (defun my-ac-haskell-mode ()
>>        (setq ac-sources '(ac-source-words-in-same-mode-buffers
>>                           ac-source-dictionary
>>                           ac-source-ghc-mod)))
>>      (add-hook 'haskell-mode-hook 'my-ac-haskell-mode)
>> 
>> 
>>      (defun my-haskell-ac-init ()
>>        (when (member (file-name-extension buffer-file-name) '("hs" "lhs"))
>>          (auto-complete-mode t)
>>          (setq ac-sources '(ac-source-words-in-same-mode-buffers
>>                             ac-source-dictionary
>>                             ac-source-ghc-mod))))
>>      (add-hook 'find-file-hook 'my-haskell-ac-init)))
>> 
>> (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))
>> 
>> 
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>> 
>> 
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140421/bede5bca/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140421/bede5bca/attachment.sig>


More information about the Haskell-Cafe mailing list