haskell / haskell/cabal

Using :load from within `cabal repl` can cause `-Wmissing-home-modules` to go haywire

Open
#4,711 1 comment 7 reactions 0 assignees View on GitHub
Cabal: cmd/repl type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I often `cabal repl` into a project and then `:load` into another module so that I can test changes from that project on the module. However, this workflow confuses `cabal-install`'s integration with GHC's `-Wmissing-home-modules` flag. To see what I mean, first prepare this Haskell file:

```haskell
module Foo where

import Control.Monad.Cont
```

And then do the following:

```
$ cabal get mtl-2.2.1
Unpacking to mtl-2.2.1/
$ cd mtl-2.2.1/
$ cabal repl
Resolving dependencies...
Configuring mtl-2.2.1...
Preprocessing library for mtl-2.2.1..
GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[ 1 of 22] Compiling Control.Monad.Cont.Class ( Control/Monad/Cont/Class.hs, interpreted )
[ 2 of 22] Compiling Control.Monad.Error.Class ( Control/Monad/Error/Class.hs, interpreted )
[ 3 of 22] Compiling Control.Monad.Identity ( Control/Monad/Identity.hs, interpreted )
[ 4 of 22] Compiling Control.Monad.Reader.Class ( Control/Monad/Reader/Class.hs, interpreted )
[ 5 of 22] Compiling Control.Monad.State.Class ( Control/Monad/State/Class.hs, interpreted )
[ 6 of 22] Compiling Control.Monad.Trans ( Control/Monad/Trans.hs, interpreted )
[ 7 of 22] Compiling Control.Monad.State.Strict ( Control/Monad/State/Strict.hs, interpreted )
[ 8 of 22] Compiling Control.Monad.State.Lazy ( Control/Monad/State/Lazy.hs, interpreted )
[ 9 of 22] Compiling Control.Monad.State ( Control/Monad/State.hs, interpreted )
[10 of 22] Compiling Control.Monad.Reader ( Control/Monad/Reader.hs, interpreted )
[11 of 22] Compiling Control.Monad.List ( Control/Monad/List.hs, interpreted )
[12 of 22] Compiling Control.Monad.Except ( Control/Monad/Except.hs, interpreted )
[13 of 22] Compiling Control.Monad.Error ( Control/Monad/Error.hs, interpreted )
[14 of 22] Compiling Control.Monad.Cont ( Control/Monad/Cont.hs, interpreted )
[15 of 22] Compiling Control.Monad.Writer.Class ( Control/Monad/Writer/Class.hs, interpreted )
[16 of 22] Compiling Control.Monad.RWS.Class ( Control/Monad/RWS/Class.hs, interpreted )
[17 of 22] Compiling Control.Monad.RWS.Strict ( Control/Monad/RWS/Strict.hs, interpreted )
[18 of 22] Compiling Control.Monad.RWS.Lazy ( Control/Monad/RWS/Lazy.hs, interpreted )
[19 of 22] Compiling Control.Monad.RWS ( Control/Monad/RWS.hs, interpreted )
[20 of 22] Compiling Control.Monad.Writer.Lazy ( Control/Monad/Writer/Lazy.hs, interpreted )
[21 of 22] Compiling Control.Monad.Writer ( Control/Monad/Writer.hs, interpreted )
[22 of 22] Compiling Control.Monad.Writer.Strict ( Control/Monad/Writer/Strict.hs, interpreted )
Ok, 22 modules loaded.
λ> :l ../Foo.hs

: warning: [-Wmissing-home-modules]
These modules are needed for compilation but not listed in your .cabal file's other-modules: Control.Monad.Cont
Control.Monad.Cont.Class
Control.Monad.Trans
[1 of 4] Compiling Control.Monad.Cont.Class ( Control/Monad/Cont/Class.hs, interpreted )
[2 of 4] Compiling Control.Monad.Trans ( Control/Monad/Trans.hs, interpreted )
[3 of 4] Compiling Control.Monad.Cont ( Control/Monad/Cont.hs, interpreted )
[4 of 4] Compiling Foo ( ../Foo.hs, interpreted )
Ok, 4 modules loaded.
```

Why should `-Wmissing-home-modules` be firing here?

```
$ cabal --version
cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.1
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the warning with the supplied Foo.hs example, mtl-2.2.1, and `cabal repl`, then trace cabal-install's `cabal repl` integration around GHC's `-Wmissing-home-modules` handling. Done means the `:load` workflow no longer emits an inappropriate missing-home-modules warning while normal warning behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.