New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ghci to shebang system #2510

Closed
enolan opened this Issue Aug 17, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@enolan
Contributor

enolan commented Aug 17, 2016

Often, I want to send someone a small Haskell file to open in the interpreter for e.g. a bug report against a library or a StackOverflow answer. It'd be nice to be able to use the shebang system (or something like it) and have Stack open the file in ghci with the appropriate packages/GHC/etc in place. Concretely, this script

#!/usr/bin/env stack
{-
stack
  --resolver lts-6.9
  --install-ghc
  ghci
  --package unbound-0.4.4
  --package RepLib-0.5.3.5
-}

main = return ()

fails with

$ stack ~/junk/unbound-bug.hs
Invalid argument `ghci'
Error executing interpreter command: stack --resolver lts-6.9 --install-ghc ghci --package unbound-0.4.4 --package RepLib-0.5.3.5 -- /home/enolan/junk/unbound-bug.hs

Usage: stack [--help] [--version] [--numeric-version] [--hpack-numeric-version]
             [--docker*] [--nix*] ([--verbosity VERBOSITY] | [-v|--verbose] |
             [--silent]) [--stack-root STACK-ROOT] [--work-dir WORK-DIR]
             [--[no-]system-ghc] [--[no-]install-ghc] [--arch ARCH] [--os OS]
             [--ghc-variant VARIANT] [-j|--jobs JOBS] [--extra-include-dirs DIR]
             [--extra-lib-dirs DIR] [--[no-]skip-ghc-check] [--[no-]skip-msys]
             [--local-bin-path DIR] [--[no-]modify-code-page]
             [--[no-]allow-different-user] [--resolver RESOLVER]
             [--compiler COMPILER] [--[no-]terminal] [--stack-yaml STACK-YAML]
             COMMAND|FILE

Changing ghci to runghc runs it as expected. Running stack ghci ~/junk/unbound-bug.hs results in Error parsing targets: Directory not found: /home/enolan/junk/unbound-bug.hs regardless of if the file has runghc or ghci in it. Ideally, both stack ghci $FILENAME and writing ghci instead of runghc in the header comment would open the interpreter shell.

Version 1.1.2, Git revision cebe10e845fed4420b6224d97dcabf20477bbd4b (3646 commits) x86_64 hpack-0.14.0

@harendra-kumar

This comment has been minimized.

Collaborator

harendra-kumar commented Aug 18, 2016

Interpreter does not allow commands other than runghc. I contemplated allowing ghci case in interpreter but was wondering if someone would need this and here you are. I will happily enable this.

Another problem is that stack ghci does not work as you would think on single files. You can use stack exec ghci though.

@enolan

This comment has been minimized.

Contributor

enolan commented Aug 18, 2016

Cool!

On Wed, Aug 17, 2016, 8:45 PM Harendra Kumar notifications@github.com
wrote:

Interpreter does not allow commands other than runghc. I contemplated
allowing ghci case in interpreter but was wondering if someone would need
this and here you are. I will happily enable this.

Another problem is that stack ghci does not work as you would think on
single files. You can use stack exec ghci though.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2510 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADwTbsdhaUuWIJ_NvQ7TLrV7fjsINM8ks5qg9U6gaJpZM4Jm3un
.

@harendra-kumar

This comment has been minimized.

Collaborator

harendra-kumar commented Aug 18, 2016

Fixed via commit d5b8c6e . Use exec ghci instead of ghci in the shebang comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment