[GHC] #9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Like many programming language environments, GHC offers a handy `-e` option for evaluating an expression, then returning to the shell. {{{ $ ghc -e '2 + 2' 4 }}} One would expect the interpreter, GHCi, to offer a similar flag, but it surprisingly rejects it. {{{ ghci -e '2 + 2' ghc: on the commandline: cannot use `--interactive' with `-e' Usage: For basic information, try the `--help' option. }}} I think this behavior is quite unintuitive--when I pass `-e <exp>` to ghci, or pass `--interactive -e <exp>` to ghc, I expect the expression to be evaluated as the leading expression in an interactive interpreter session. Could we please tweak ghc like this to make it slightly more intuitive when these flags are used together? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.2 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by nomeata):
I expect the expression to be evaluated as the leading expression in an interactive interpreter session.
Do you mean that the expression should be evaluated, the result printed, and then you’d end up at the GHCi prompt? I would rather expect `ghci -e` to simply behave like `ghc -e`. Note that python and perl will either evaluate an expression from the command line *or* give you the REPL loop. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.2 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by mcandre): Either of two behaviors would be great: * Just the expression evaluates, prints, and the user is returned to the terminal shell prompt. * The expression becomes the first thing run and printed in a normal ghci session. I don't mind which of these happens, as long as ghc does one of them. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.2 Component: GHCi | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: #9799 None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * cc: hvr (added) * component: Compiler => GHCi * related: => #9799 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * keywords: => newcomer * related: #9799 => Comment: The function to change is called `setMode` in `ghc/Main.hs`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by lukyanov): With my patch {{{ghci -e}}} will simply behave like {{{ghc -e}}}. Example: {{{ $ ./ghc-stage2 --interactive -e "2^10" 1024 $ ./ghc-stage2 -e "2^10" --interactive 1024 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): @lukyanov: could you add a test (sometimes more work than making the code change itself), and submit a code review to [wiki:Phabricator]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: lukyanov Type: feature request | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by lukyanov): * owner: => lukyanov -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: lukyanov Type: feature request | Status: patch Priority: normal | Milestone: 8.0.1 Component: GHCi | Version: 7.8.2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: driver/T9360a | driver/T9360b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1337 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => patch * testcase: => driver/T9360a driver/T9360b * differential: => Phab:D1337 * milestone: => 8.0.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs
-------------------------------------+-------------------------------------
Reporter: mcandre | Owner: lukyanov
Type: feature request | Status: patch
Priority: normal | Milestone: 8.0.1
Component: GHCi | Version: 7.8.2
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: driver/T9360a
| driver/T9360b
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1337
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Thomas Miedema

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: lukyanov Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: GHCi | Version: 7.8.2 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: driver/T9360a | driver/T9360b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1337 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: patch => closed * resolution: => fixed Comment: Thanks for the patch lukyanov. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9360: GHCi: Behave nicely on `-e`, like `ghc` and other programs -------------------------------------+------------------------------------- Reporter: mcandre | Owner: lukyanov Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: GHCi | Version: 7.8.2 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: driver/T9360a | driver/T9360b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1337 Wiki Page: | -------------------------------------+------------------------------------- Comment (by lukyanov): Replying to [comment:10 thomie]:
Thanks for the patch lukyanov. You're welcome. Sorry I didn't submit it to Phabricator myself.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9360#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC