Skip to content

Automatically create process when opening haskell files #729

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

Closed
geraldus opened this issue Jun 18, 2015 · 4 comments
Closed

Automatically create process when opening haskell files #729

geraldus opened this issue Jun 18, 2015 · 4 comments

Comments

@geraldus
Copy link
Contributor

I can't be certain, but I believe in past haskell-interactive-mode asked me to start new process each time project file opened (I can't speak about single *.hs files, because I use them very rarely), but now it's not true. It's just silently opens file.

Is there some benefits of interactive mode without active process over plain haskell mode?

To activate interactive mode I have following in my init file:

(require 'haskell-interactive-mode)
(add-hook 'haskell-mode-hook #'interactive-haskell-mode)
@ivan-m
Copy link
Contributor

ivan-m commented Jun 19, 2015

What happens if you only want to read a file from another project without actually running it (you want to verify how you wrote something, etc.)?

Or you're writing Haskell-y pseudo-code which isn't expected to actually run?

@geraldus
Copy link
Contributor Author

@ivan-m well, this is good question.

The real issue is that there are four steps to bring REPL, and even if you answer "no" to first question ("start new project?") there follows another one ("choose haskell session"). I think if user answered "no", there should be no other questions.

One thing I can think of is not to ask user about project name, but assign some better names automatically (also a question "start a new project" is very confusing for newcomers). I do not like default naming, at least it's be better to keep case in the project name, and typing custom name is too boring for me.

Another point is working directory (this is last question I believe), I guess in cases of project workdir should be the same as cabal file dir by default (I can't be certain). For example, here is possible behaviour:

  • when cabal file found
    • ask user "load entire project? yes, no, select another cabal file" (RET defaults to yes)
    • if user answered "yes" — set pwd to cabal file dir and load REPL
    • if user answered "no" — ask for working directory and load single file
    • if user answered "select other" — ask for cabal file location
  • if cabal file not found
    • prompt user "cabal file not found, set working directory or specify cabal file location" (RET defaults to directory selection, some other key to cabal file location)

So, if interactive mode is enabled:

  • when opening project file assign it to project's session if present (one caveat: we need to know is file listed in modules or other modules sections)
  • if no session ask user about new one as described below
  • when opening a file without a project, ask user as described below
  • prevention of new session creation should be done by single keystroke.

What do you think?

@ivan-m
Copy link
Contributor

ivan-m commented Jun 19, 2015

For why you are asked to choose a session after you say you don't want to create a project: if you want to do some kind of session-based interaction (which is often also done in the save hook) and you don't want to create a new session, then you need to pick one that already exists... this is also useful when the automatic session-detection doesn't work properly. Of course, there should probably be a "no and I don't want to run it in a session" option.

What do you mean by "assign better names automatically"? If it's a cabalised project then what better name could there be? If it isn't cabalised, well... maybe it could try and pick a name based upon the directory rather than just wanting to call it haskell. (Though "start a new project" could possibly be better worded as "start a new Haskell session".)

What does "load entire project" mean? To me, it indicates that ever single source file should be loaded into ghci, which I usually don't want.

Whilst you almost definitely want the default options for directory, etc. there may be cases you don't (you may wish to have the current directory to be a sub-directory so that you can refer to other hierarchical modules relatively within that sub-directory which isn't listed in the cabal file's hs-source-dirs).

I also don't understand why there should be that caveat regarding a file being in modules or other-modules: if it's in other-modules yet you're hacking upon it, you'll still want to load it as normal, etc. Within a project which setting it is listed under shouldn't matter, it's only for external access of that module. Also, you may have testing scripts, etc. that aren't listed in either modules or other-modules (or might be listed in one for a different target in the cabal file).

There's also a situation that I'm facing where I have a sub-project within the main project; currently, it often thinks that modules belonging to the sub-project should be loaded in the session for the main project (and what makes it more confusing is that there is one module that is used by both, hence why I have them in the same repository).

Ideally you'd be able to customise more of this behaviour, and even use .dir-local.el files for per-project settings; see #409 for previous discussions on this.

@geraldus
Copy link
Contributor Author

geraldus commented Jul 5, 2015

Let's close this until we have some better proposal.

@geraldus geraldus closed this as completed Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants