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

"mafia ghci" doesn't understand flags in cabal file #172

Open
erikd-ambiata opened this issue Apr 27, 2017 · 6 comments
Open

"mafia ghci" doesn't understand flags in cabal file #172

erikd-ambiata opened this issue Apr 27, 2017 · 6 comments

Comments

@erikd-ambiata
Copy link
Contributor

Messing with the tls package using mafia ghci Network/TLS/Backend.hs I get:

> mafia ghci Network/TLS/Backend.hs 
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/erikd/.ghci
[1 of 1] Compiling Network.TLS.Backend ( Network/TLS/Backend.hs, interpreted )

Network/TLS/Backend.hs:62:13: error:
    Not in scope: type constructor or class ‘Network.Socket’
    No module named ‘Network’ is imported.

Network/TLS/Backend.hs:64:12: error:
    Not in scope: ‘Network.recv’
    No module named ‘Network’ is imported.
Failed, modules loaded: none.

Problem is that the include of Network.Socket is guarded:

#ifdef INCLUDE_NETWORK
import Control.Monad
import qualified Network.Socket as Network (Socket, close)
import qualified Network.Socket.ByteString as Network
#endif

with a flag set in the cabal file:

Flag network
  Description:       Use the base network library
  Default:           True

Mafia can build this just fine, but its a pity I can't just load it into GHCi.

@amosr
Copy link
Contributor

amosr commented Apr 27, 2017

out of curiosity, does mafia repl work? might suffice as a workaround for now

@erikd-ambiata
Copy link
Contributor Author

Indeed it does. Curious!

@markhibberd
Copy link
Contributor

That is the explicit difference between repl and ghci. repl uses cabal and related info, ghci is for using ghc directly and explicitly ignoring anything to do with cabal.

@erikd-ambiata
Copy link
Contributor Author

explicitly ignoring anything to do with cabal

It doesn't ignore everything to do with cabal. For instance, it uses the local cabal sandbox. The ghci command only exists to work around what I consider a bug in cabal's repl command, ie that you can't tell cabal repl to load a file that is not mentioned in the cabal file. If that bug was fixed, I think the desired behavior of repl and ghci could actually be the same.

@markhibberd
Copy link
Contributor

Ok, that is not what I use it for, repl is project based, ghci is file based, this distinction has always existed and wasn't to work around anything. They are very different things for very different purposes for me.

@erikd-ambiata
Copy link
Contributor Author

My main use of mafia ghci is try out experimental code that is related to the current project, but may or may not end up in the current project.

If ghci was "fixed" to correctly handle flags defined in the local cabal file, would it break anything for you?

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