Skip to content

Unable to start REPL for specific project component #790

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
mrkkrp opened this issue Aug 1, 2015 · 13 comments
Closed

Unable to start REPL for specific project component #790

mrkkrp opened this issue Aug 1, 2015 · 13 comments

Comments

@mrkkrp
Copy link
Contributor

mrkkrp commented Aug 1, 2015

Hello. Previously C-c C-l asked me about project component, so I could say exe:something and it would work. Now it doesn't ask that but instead just tells me that some packages are hidden. The thing is my executable depends on these packages, while library doesn't, so it seems it tries to start REPL for library and at the same time loads code for executable (that's what I want it to do after all). I'm perplexed, how can I start REPL with respect to dependencies of my executable?

@gracjan
Copy link
Contributor

gracjan commented Aug 1, 2015 via email

@mrkkrp
Copy link
Contributor Author

mrkkrp commented Aug 1, 2015

@gracjan, this should do: https://github.com/mrkkrp/mida/blob/master/mida.cabal

For example, exe:mida has dependency directory and when I'm trying to load a file from executable component, I get error messages that directory package is hidden. It asks me if I want to add the package to my cabal file.

@gracjan
Copy link
Contributor

gracjan commented Aug 1, 2015

I try to replicate the same issue outside of haskell-mode on the command
line but I fail to achieve that. I tried:

git clone https://github.com/mrkkrp/mida.git
cabal sandbox init
cabal install --only-dep
cabal repl

And everything works. cabal repl without arguments should not ever try to
run a library.

Can you help to replicate same issue outside of haskell-mode so that we
know what cabal really needs to run smoothly?

@mrkkrp
Copy link
Contributor Author

mrkkrp commented Aug 1, 2015

@gracjan, yes it works from command line, cabal repl starts fine. Although it loads library, not executable, as you can see from list of loaded files. Also, I don't think you can run :main command there, because it's defined in executable and it's not loaded.

Here is what I get:

~/projects/programs/mida/main $ cabal repl
Preprocessing library mida-0.4.3...
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
[ 1 of 11] Compiling Mida.Representation.Base ( src/Mida/Representation/Base.hs, interpreted )
[ 2 of 11] Compiling Mida.Language.Element ( src/Mida/Language/Element.hs, interpreted )
[ 3 of 11] Compiling Mida.Language.SyntaxTree ( src/Mida/Language/SyntaxTree.hs, interpreted )
[ 4 of 11] Compiling Mida.Representation.Parser ( src/Mida/Representation/Parser.hs, interpreted )
[ 5 of 11] Compiling Mida.Representation.Show ( src/Mida/Representation/Show.hs, interpreted )
[ 6 of 11] Compiling Mida.Language.Environment ( src/Mida/Language/Environment.hs, interpreted )
[ 7 of 11] Compiling Mida.Language.Eval ( src/Mida/Language/Eval.hs, interpreted )
[ 8 of 11] Compiling Mida.Representation ( src/Mida/Representation.hs, interpreted )
[ 9 of 11] Compiling Mida.Language    ( src/Mida/Language.hs, interpreted )
[10 of 11] Compiling Mida.Midi        ( src/Mida/Midi.hs, interpreted )
[11 of 11] Compiling Mida.Configuration ( src/Mida/Configuration.hs, interpreted )
Ok, modules loaded: Mida.Configuration, Mida.Language, Mida.Language.SyntaxTree, Mida.Language.Element, Mida.Language.Environment, Mida.Language.Eval, Mida.Representation, Mida.Representation.Base, Mida.Representation.Show, Mida.Midi, Mida.Representation.Parser.
λ> :main

<interactive>:2:53:
    Not in scope: ‘main’
    Perhaps you meant ‘min’ (imported from Prelude)
λ> :quit
Leaving GHCi.

And here is what should actually happen:

~/projects/programs/mida/main $ cabal repl exe:mida
Preprocessing library mida-0.4.3...
In-place registering mida-0.4.3...
Preprocessing executable 'mida' for mida-0.4.3...
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
[ 1 of 15] Compiling Mida.Representation.Base ( src/Mida/Representation/Base.hs, interpreted )
[ 2 of 15] Compiling Mida.Language.SyntaxTree ( src/Mida/Language/SyntaxTree.hs, interpreted )
[ 3 of 15] Compiling Mida.Representation.Parser ( src/Mida/Representation/Parser.hs, interpreted )
[ 4 of 15] Compiling Mida.Language.Element ( src/Mida/Language/Element.hs, interpreted )
[ 5 of 15] Compiling Mida.Representation.Show ( src/Mida/Representation/Show.hs, interpreted )
[ 6 of 15] Compiling Mida.Language.Environment ( src/Mida/Language/Environment.hs, interpreted )
[ 7 of 15] Compiling Mida.Language.Eval ( src/Mida/Language/Eval.hs, interpreted )
[ 8 of 15] Compiling Mida.Representation ( src/Mida/Representation.hs, interpreted )
[ 9 of 15] Compiling Mida.Language    ( src/Mida/Language.hs, interpreted )
[10 of 15] Compiling Mida.Midi        ( src/Mida/Midi.hs, interpreted )
[11 of 15] Compiling Mida.Interaction.Base ( src/Mida/Interaction/Base.hs, interpreted )
[12 of 15] Compiling Mida.Interaction.Commands ( src/Mida/Interaction/Commands.hs, interpreted )
[13 of 15] Compiling Mida.Interaction ( src/Mida/Interaction.hs, interpreted )
[14 of 15] Compiling Mida.Configuration ( src/Mida/Configuration.hs, interpreted )
[15 of 15] Compiling Main             ( src/Main.hs, interpreted )
Ok, modules loaded: Mida.Configuration, Mida.Language, Mida.Language.Element, Mida.Language.Environment, Mida.Language.Eval, Mida.Language.SyntaxTree, Mida.Midi, Mida.Representation, Mida.Representation.Parser, Mida.Representation.Show, Mida.Representation.Base, Main, Mida.Interaction, Mida.Interaction.Base, Mida.Interaction.Commands.
λ> :main
MIDA Copyright © 2014, 2015 Mark Karpov

This program comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions; see
GNU General Public License for details.

MIDA Interactive Environment 0.4.3
> :quit
*** Exception: ExitSuccess
λ> :quit
Leaving GHCi.

I never liked all these questions on startup but that one about component was useful...

@mrkkrp
Copy link
Contributor Author

mrkkrp commented Aug 1, 2015

@gracjan, is it possible to detect component using .cabal file and buffer-file-name? Then you could use it to start REPL.

@gracjan
Copy link
Contributor

gracjan commented Aug 1, 2015

I see. Use haskell-process-load-or-reload-prompt and set it to t. That gives you previous behavior.

And thanks for reporting real life scenario where it is useful to specify arguments to cabal repl.

@gracjan
Copy link
Contributor

gracjan commented Aug 5, 2015

This exe:mida syntax is something new...

@mrkkrp
Copy link
Contributor Author

mrkkrp commented Aug 5, 2015

@gracjan, as far as I know this is how you select particular executable component. This may be especially useful when you have several executables in one project.

@ivan-m
Copy link
Contributor

ivan-m commented Aug 7, 2015

With haskell-mode, there's haskell-session-change-target to get that same behaviour.

(I keep meaning to try and see if it's possible to scan the .cabal file and populate the available list of targets using ido to select...)

@gracjan
Copy link
Contributor

gracjan commented Aug 7, 2015 via email

@gracjan
Copy link
Contributor

gracjan commented Aug 8, 2015

@mrkkrp: Can you confirm that setting haskell-process-load-or-reload-prompt to t solves your problem?

@mrkkrp
Copy link
Contributor Author

mrkkrp commented Aug 8, 2015

@gracjan, well, yes, but it asks too many questions for my taste (this isn't really a problem, though). Also, please add one space after "build target (empty for default):" and it would really make sense to use completing read and list of build targets extracted from .cabal file when asking about build target.

Also, if I press C-g before I finish answering the questions, some REPL buffer is created anyway. I find it confusing.

Apart from these issues, it works OK. If you can wait sufficiently long, I can edit all the stuff and open a pull request, but it may take up to month.

@gracjan
Copy link
Contributor

gracjan commented Aug 8, 2015 via email

@mrkkrp mrkkrp closed this as completed Aug 8, 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

3 participants