<div dir="ltr"><div><div>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<br>
<br></div>library<br></div><div>  exposed-modules: Lib<br></div>  hs-source-dirs: src/lib<br><div><div><br>test-suite sometest<br>  type:           exitcode-stdio-1.0<br>  main-is:        Test.hs<br>  hs-source-dirs: src/test src/lib<br>
<br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 18 April 2014 16:20, Arnaud Bailly <span dir="ltr"><<a href="mailto:arnaud.oqube@gmail.com" target="_blank">arnaud.oqube@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello,<div><br><div>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</div>
<div><br></div><div>> :set -iwhere/my/src/are</div><div><br></div><div>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?</div>
</div><div><br></div><div>Here is my .emacs configuration. Thanks for any help.<br></div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(215,57,30)">;; haskell coding                                                                                                                                                                                           </div>
<div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(52,162,161)"><span style="color:#000000">(</span><span style="color:#d03cff">require</span><span style="color:#000000"> '</span>auto-complete<span style="color:#000000">)</span></div>
<div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(52,162,161)"><span style="color:#000000">(</span><span style="color:#d03cff">require</span><span style="color:#000000"> '</span>haskell-mode<span style="color:#000000">)</span></div>
<div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(52,162,161)"><span style="color:#000000">(</span><span style="color:#d03cff">require</span><span style="color:#000000"> '</span>haskell-cabal<span style="color:#000000">)</span></div>
<div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">(autoload 'ghc-init <span style="color:#af3782">"ghc"</span> nil t)</div>
<div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">(add-hook 'haskell-mode-hook (<span style="color:#d03cff">lambda</span> () (ghc-init)))</div>
<div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(208,60,255)"><span style="color:#000000">(</span>eval-after-load<span style="color:#000000"> </span><span style="color:#af3782">"haskell-mode"</span></div>
<div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(208,60,255)"><span style="color:#000000">  '(</span>progn</div><div style="margin:0px;font-size:11px;font-family:Menlo">     (setq haskell-stylish-on-save t)</div>
<div style="margin:0px;font-size:11px;font-family:Menlo">     (setq haskell-process-args-cabal-repl '(<span style="color:#af3782">"--ghc-option=-ferror-spans"</span></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(175,55,130)">
<span style="color:#000000">               </span>"--with-ghc=ghci-ng"<span style="color:#000000">))</span></div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">
     (define-key haskell-mode-map (kbd <span style="color:#af3782">"C-,"</span>) 'haskell-move-nested-left)</div><div style="margin:0px;font-size:11px;font-family:Menlo">     (define-key haskell-mode-map (kbd <span style="color:#af3782">"C-."</span>) 'haskell-move-nested-right)</div>
<div style="margin:0px;font-size:11px;font-family:Menlo">     (define-key haskell-mode-map (kbd <span style="color:#af3782">"C-c v c"</span>) 'haskell-cabal-visit-file)</div><div style="margin:0px;font-size:11px;font-family:Menlo">
     (define-key haskell-mode-map (kbd <span style="color:#af3782">"C-c C-c"</span>) 'haskell-compile)</div><div style="margin:0px;font-size:11px;font-family:Menlo">     (define-key haskell-mode-map (kbd <span style="color:#af3782">"C-x C-d"</span>) nil)</div>
<div style="margin:0px;font-size:11px;font-family:Menlo">     (setq haskell-font-lock-symbols t)</div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(215,57,30)">
<span style="color:#000000">     </span>;; Do this to get a variable in scope                                                                                                                                                                  </div>
<div style="margin:0px;font-size:11px;font-family:Menlo">     (auto-complete-mode)</div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(215,57,30)">
<span style="color:#000000">     </span>;; from <a href="http://pastebin.com/tJyyEBAS" target="_blank">http://pastebin.com/tJyyEBAS</a>                                                                                                                                                                   </div>
<div style="margin:0px;font-size:11px;font-family:Menlo">     (ac-define-source ghc-mod</div><div style="margin:0px;font-size:11px;font-family:Menlo">       '((depends ghc)</div><div style="margin:0px;font-size:11px;font-family:Menlo">
         (candidates . (ghc-select-completion-symbol))</div><div style="margin:0px;font-size:11px;font-family:Menlo">         (symbol . <span style="color:#af3782">"s"</span>)</div><div style="margin:0px;font-size:11px;font-family:Menlo">
         (cache)))</div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(94,52,255)"><span style="color:#000000">     (</span><span style="color:#d03cff">defun</span><span style="color:#000000"> </span>my-ac-haskell-mode<span style="color:#000000"> ()</span></div>
<div style="margin:0px;font-size:11px;font-family:Menlo">       (setq ac-sources '(ac-source-words-in-same-mode-buffers</div><div style="margin:0px;font-size:11px;font-family:Menlo">                          ac-source-dictionary</div>
<div style="margin:0px;font-size:11px;font-family:Menlo">                          ac-source-ghc-mod)))</div><div style="margin:0px;font-size:11px;font-family:Menlo">     (add-hook 'haskell-mode-hook 'my-ac-haskell-mode)</div>
<div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(94,52,255)">
<span style="color:#000000">     (</span><span style="color:#d03cff">defun</span><span style="color:#000000"> </span>my-haskell-ac-init<span style="color:#000000"> ()</span></div><div style="margin:0px;font-size:11px;font-family:Menlo">
       (<span style="color:#d03cff">when</span> (member (file-name-extension buffer-file-name) '(<span style="color:#af3782">"hs"</span> <span style="color:#af3782">"lhs"</span>))</div><div style="margin:0px;font-size:11px;font-family:Menlo">
         (auto-complete-mode t)</div><div style="margin:0px;font-size:11px;font-family:Menlo">         (setq ac-sources '(ac-source-words-in-same-mode-buffers</div><div style="margin:0px;font-size:11px;font-family:Menlo">
                            ac-source-dictionary</div><div style="margin:0px;font-size:11px;font-family:Menlo">                            ac-source-ghc-mod))))</div><div style="margin:0px;font-size:11px;font-family:Menlo">
     (add-hook 'find-file-hook 'my-haskell-ac-init)))</div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan)</div>
<div style="margin:0px;font-size:11px;font-family:Menlo">(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)</div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(208,60,255)">
<span style="color:#000000">(</span>eval-after-load<span style="color:#000000"> </span><span style="color:#af3782">"which-func"</span></div><div style="margin:0px;font-size:11px;font-family:Menlo">  '(add-to-list 'which-func-modes 'haskell-mode))</div>
<div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(208,60,255)"><span style="color:#000000">(</span>eval-after-load<span style="color:#000000"> </span><span style="color:#af3782">"haskell-cabal"</span></div>
<div style="margin:0px;font-size:11px;font-family:Menlo">    '(define-key haskell-cabal-mode-map (kbd <span style="color:#af3782">"C-c C-c"</span>) 'haskell-compile))</div></div><div><br></div></div><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>