commercialhaskell / commercialhaskell/stack

stack ghci: enable use of Stack interpreter options comment when loading script file

Open
#5,061 3 comments 0 reactions 0 assignees View on GitHub
component: ghci type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

Say you have a [script](https://github.com/commercialhaskell/stack/wiki/Script-interpreter):

```haskell
#!/usr/bin/env stack
{-
stack
script
--resolver lts-14.2
--package adler32
-}

import Data.Digest.Adler32

main = print "HI"
```

It'd be nice if you could just `stack ghci script.hs`, but ghci can't find modules ❌

```
/path/to/script.hs:9:1: error:
Could not find module ‘Data.Digest.Adler32’
Use -v to see a list of the files searched for.
|
9 | import Data.Digest.Adler32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
```

...until you run it with once with `stack ghci --package adler32 script.hs`. After that, `stack ghci script.hs` works.

I'm interested in fixing this. Any tips on where to start?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.