Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guess working directory from hs-source-dirs? #191

Closed
karljs opened this issue Jul 28, 2013 · 6 comments
Closed

Guess working directory from hs-source-dirs? #191

karljs opened this issue Jul 28, 2013 · 6 comments

Comments

@karljs
Copy link
Contributor

karljs commented Jul 28, 2013

I imagine the large majority of projects using Cabal tend to have a single directory under which all their source files are placed, such as $PROJECT_ROOT/src. Given this, doesn't it make sense to try guessing the current directory based on the required cabal property hs-source-dirs when starting a new project?

Apologies if this is a bad suggestion as I'm not familiar with best practices when it comes to packaging Haskell code.

@hvr
Copy link
Member

hvr commented Jul 28, 2013

Your suggestion is totally sensible, here's the current state:

  • In one place, specifically inferior-haskell-find-project-root, hs-source-dirs is taken into consideration (but it's a very crude heuristic)
  • Properly interpreting hs-source-dirs requires to
    • Decide whose build-target's (i.e. library, executable *, benchmark *, test-suite *) hs-source-dirs to take
    • Handling conditional statements which can influence the final value of hs-source-dirs
    • How to handle multiple hs-source-dirs (which for GHCi translate to multiple -i flags)

This is something we definitely need to tackle sooner or later, but right now it seems to me we need an external tool for that (using the Cabal library for parsing & interpreting the current package configuration state).

PS: This issue slightly related to #180

@svenpanne
Copy link
Contributor

I am using haskell-mode 13.7 from http://marmalade-repo.org/packages/haskell-mode, and things almost work: hs-source-dirs is honored, but only at the beginning of a line. The downside is that almost no .cabal file has it there, it is almost always indeted. A quick local fix for the first regexp in haskell-cabal-get-setting (allowing tabs and spaces before the name) works for me, but I don't have a clue if this is the right fix.

It would be nice if this could be fixed, as it is, the current feature is next to useless for lots of packages out there, which is a pity for such a useful thing.

@gracjan
Copy link
Contributor

gracjan commented Mar 27, 2015

When using cabal repl the current directory is the directory where *.cabal file resides. Are you talking about some other current directory? Or what?

@gracjan
Copy link
Contributor

gracjan commented Apr 4, 2015

In the somewhat related issue #180 it was hinted that cabal repl is the way to go. In general cabal repl is when you have .cabal file and ghci is only when you do not have it. Implementing more logic would be very fragile and user unfriendly.

I'm closing this issue, if I misunderstood something write a comment or reopen.

@gracjan gracjan closed this as completed Apr 4, 2015
@svenpanne
Copy link
Contributor

How is cabal repl related to editing Haskell source files?

@gracjan
Copy link
Contributor

gracjan commented Apr 4, 2015

@svenpanne: I do not understand your question. Can you elaborate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants