stack ghci <file>

Created on 18 Nov 2015  路  5Comments  路  Source: commercialhaskell/stack

Is it possible to load a single module into ghci, outside of a project?

> stack ghci foo.hs
Run from outside a project, using implicit global project config
Using resolver: lts-3.10 from implicit global project's config file: /Users/mrosen/.stack/global-project/stack.yaml
Error parsing targets: Directory not found: foo.hs
awaiting pull request ghci enhancement

Most helpful comment

This has been implemented! One caveat is that you cannot specify both normal targets and file targets. The logic for specifying both would have been complicated, so I took the easy way out.

All 5 comments

Not currently, but it's a good idea. I'd also like to support loading files from the project, and have it figure out which cabal components to load.

The way to do this is stack ghci, then within the repl, :load foo.hs. Or, within a project, stack exec ghci followed by :load foo.hs.

Within a project, is stack ghci not equivalent to stack exec ghci?

It isn't - with v0.1.6, stack ghci loads up every cabal component for every local package. On the latest dev branch, it now loads up all the library / executable components, consistent with stack build. I did consider having stack ghci load up no components - see #1307. If there's demand for this behavior, I wouldn't mind making the change.

It'd also be good to be able to support stack ghci Foo.Bar.Baz, or stack ghci --module Foo.Bar.Baz (otherwise we might be overloading TARGET with a few too many ways to parse)

This has been implemented! One caveat is that you cannot specify both normal targets and file targets. The logic for specifying both would have been complicated, so I took the easy way out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cybaj picture cybaj  路  3Comments

bitemyapp picture bitemyapp  路  3Comments

sjakobi picture sjakobi  路  4Comments

mgsloan picture mgsloan  路  3Comments

symbiont-joseph-kachmar picture symbiont-joseph-kachmar  路  3Comments