mafia icon indicating copy to clipboard operation
mafia copied to clipboard

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

Open erikd-ambiata opened this issue 7 years ago • 6 comments

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.

erikd-ambiata avatar Apr 27 '17 23:04 erikd-ambiata

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

amosr avatar Apr 27 '17 23:04 amosr

Indeed it does. Curious!

erikd-ambiata avatar Apr 27 '17 23:04 erikd-ambiata

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.

markhibberd avatar Apr 27 '17 23:04 markhibberd

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.

erikd-ambiata avatar Apr 27 '17 23:04 erikd-ambiata

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.

markhibberd avatar Apr 27 '17 23:04 markhibberd

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?

erikd-ambiata avatar Apr 27 '17 23:04 erikd-ambiata