Quantcast

How can I use “cabal repl” without base

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How can I use “cabal repl” without base

Adam Steen-2
Hi

How can I use cabal repl (ghci) without base?

The following contrived example shows the error

-- minimal.hs
module Minimal where

myId :: a -> a
myId x = x

and

-- minimal.cabal
name: minimal
version: 0.0.1
build-type: Simple
cabal-version: >= 1.10

library
  exposed-modules: Minimal
  --build-depends: base
  default-language: Haskell2010
  default-extensions:  NoImplicitPrelude

cabal build succeeds

$ cabal build
Building minimal-0.0.1...
Preprocessing library minimal-0.0.1...
[1 of 1] Compiling Minimal          ( Minimal.hs, dist\build\Minimal.o )

but cabal repl fails

$ cabal repl
Preprocessing library minimal-0.0.1...
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help

<interactive>:1:6: error:
    Not in scope: `System.IO.hSetBuffering'
    No module named `System.IO' is imported.

<interactive>:1:30: error:
    Not in scope: `System.IO.stdin'
    No module named `System.IO' is imported.

<interactive>:1:46: error:
    Not in scope: data constructor `System.IO.NoBuffering'
    No module named `System.IO' is imported.

<interactive>:1:70: error:
    Not in scope: `System.IO.hSetBuffering'
    No module named `System.IO' is imported.

<interactive>:1:94: error:
    Not in scope: `System.IO.stdout'
    No module named `System.IO' is imported.

<interactive>:1:111: error:
    Not in scope: data constructor `System.IO.NoBuffering'
    No module named `System.IO' is imported.

<interactive>:1:135: error:
    Not in scope: `System.IO.hSetBuffering'
    No module named `System.IO' is imported.

<interactive>:1:159: error:
    Not in scope: `System.IO.stderr'
    No module named `System.IO' is imported.

<interactive>:1:176: error:
    Not in scope: data constructor `System.IO.NoBuffering'
    No module named `System.IO' is imported.

if i restore "build-depends: base" if works as expected.

$ cabal repl
Preprocessing library minimal-0.0.1...
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Minimal          ( Minimal.hs, interpreted )
Ok, modules loaded: Minimal.
*Minimal>

i know just keeping "build-depends: base" will make it work, but thats not what i am asking.

Note: this also applies for stack

Cheers

Adam


ps this is cross posted from stackoverflow


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How can I use “cabal repl” without base

Adam Bergmark-2
This is needed for ghci to print results so i dont' think there's a workaround. You could use a cabal flag to configure your lib for repl use base conditionally, or so i assume.

Or use an exe or test suite that adds the dep.

HTH,
Adam
On Fri, 17 Mar 2017 at 12:51, Adam Steen <[hidden email]> wrote:
Hi

How can I use cabal repl (ghci) without base?

The following contrived example shows the error

-- minimal.hs
module Minimal where

myId :: a -> a
myId x = x

and

-- minimal.cabal
name: minimal
version: 0.0.1
build-type: Simple
cabal-version: >= 1.10

library
  exposed-modules: Minimal
  --build-depends: base
  default-language: Haskell2010
  default-extensions:  NoImplicitPrelude

cabal build succeeds

$ cabal build
Building minimal-0.0.1...
Preprocessing library minimal-0.0.1...
[1 of 1] Compiling Minimal          ( Minimal.hs, dist\build\Minimal.o )

but cabal repl fails

$ cabal repl
Preprocessing library minimal-0.0.1...
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help

<interactive>:1:6: error:
    Not in scope: `System.IO.hSetBuffering'
    No module named `System.IO' is imported.

<interactive>:1:30: error:
    Not in scope: `System.IO.stdin'
    No module named `System.IO' is imported.

<interactive>:1:46: error:
    Not in scope: data constructor `System.IO.NoBuffering'
    No module named `System.IO' is imported.

<interactive>:1:70: error:
    Not in scope: `System.IO.hSetBuffering'
    No module named `System.IO' is imported.

<interactive>:1:94: error:
    Not in scope: `System.IO.stdout'
    No module named `System.IO' is imported.

<interactive>:1:111: error:
    Not in scope: data constructor `System.IO.NoBuffering'
    No module named `System.IO' is imported.

<interactive>:1:135: error:
    Not in scope: `System.IO.hSetBuffering'
    No module named `System.IO' is imported.

<interactive>:1:159: error:
    Not in scope: `System.IO.stderr'
    No module named `System.IO' is imported.

<interactive>:1:176: error:
    Not in scope: data constructor `System.IO.NoBuffering'
    No module named `System.IO' is imported.

if i restore "build-depends: base" if works as expected.

$ cabal repl
Preprocessing library minimal-0.0.1...
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Minimal          ( Minimal.hs, interpreted )
Ok, modules loaded: Minimal.
*Minimal>

i know just keeping "build-depends: base" will make it work, but thats not what i am asking.

Note: this also applies for stack

Cheers

Adam


ps this is cross posted from stackoverflow

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Loading...