3

Given a cabal-project which has a data-file and a function that wants to read it.

This function f from project p does roughly the following:

module F where

import Paths_p

f = getDataFileName "datafile.dat" >>= readFile

In this file emacs haskell-mode marks the import as an error. Every other error or warning that might be in that file will never be marked.

Is there a way to make haskell-mode aware of the module Paths_p?

NobbZ
  • 1,360
  • 3
  • 15
  • 30
  • Haskell mode itself doesn't include any syntax checking, as far as i know. Do you use ghc-mod or hdevtools? – bennofs Feb 26 '14 at 11:12
  • As far as I understand my setup I have `flymake-haskell` for syntax-checking and `ghc-mod` for completion. I just switched to emacs and don't know or understand eLisp and the other emacs stuff en detail… – NobbZ Feb 26 '14 at 11:31

1 Answers1

0

Just create a file Paths_p.hs with appropriate definition of getDataFileName

MigMit
  • 1,698
  • 12
  • 14
  • Did that already, then this fake-file is used during `cabal build` which makes the compiled program fail… – NobbZ Feb 26 '14 at 12:42
  • Don't have a compiler at hand right now, but what if you just do `cabal install`? – MigMit Feb 26 '14 at 14:10
  • You don't need the fake file. If you've built your project at least once, you only need to add `dist/build/autogen/` to the import search path. – bennofs Feb 26 '14 at 14:12
  • @MigMit: It doesn't matter if I use build or install, since install just invokes build and then copies the file over to the sandbox/cabal-dir – NobbZ Feb 26 '14 at 14:16
  • @bennofs: OK, but How exactly do that? If I open the module `Something.As.Example` in emacs, I have to go 2 dirs up before I can apply the path to the dist-build. If I have dedicated src-dir, its a level more… Since emacs isn't aware of projects, the only way would be to add the autogen-dir of every single cabal-project globally which wouldn't make much sense either… – NobbZ Feb 26 '14 at 14:19
  • @NobbZ Checked it right now. Good news is that you're right on that one. Bad news is that it works wonderfully here. Do you have Paths_p in *.cabal? In the 'other-modules' section? – MigMit Feb 26 '14 at 15:38
  • 1
    Nope I haven't. I just created it at source root and put `getDataFileName` and `version` as `undefined` in there and gave the appropriate type to the functions. For now I put the autogen-dirs of my projects to the include path via `ghc-ghc-options` in `.emacs` file, but I would be very glad if I could remove that lines, since it is very ugly to maintain such a list by hand every time I start a new project, remove some or try to contribute to something opensource… – NobbZ Feb 26 '14 at 15:56