[GHC] #8047: Implement line-number %-substitution for prompt-string

#8047: Implement line-number %-substitution for prompt-string ------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.8.1 Component: GHCi | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Currently, GHCi supports the following `%`-interpolations:
`:set prompt prompt`
Sets the string to be used as the prompt in GHCi. Inside prompt, the sequence %s is replaced by the names of the modules currently in scope, and %% is replaced by %. If prompt starts with " then it is parsed as a Haskell String; otherwise it is treated as a literal string.
The attached patch implements the `%l` variable, which gets replaced by the current line number of the shown prompt. The motivation being, that compiler messages refer to interactively entered bindings by the line number when they were defined, which are a bit hard to keep track of, e.g.: {{{ λ> :set prompt "\955:%l> " λ:3> let x = () x :: () λ:4> let x = ((),()) x :: ((), ()) λ:5> print xx <interactive>:5:7: Not in scope: ‛xx’ Perhaps you meant ‛x’ (line 4) λ:6> :info x x :: ((), ()) -- Defined at <interactive>:4:5 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8047 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8047: Implement line-number %-substitution for prompt-string -------------------------------------+------------------------------------ Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.8.1 Component: GHCi | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by hvr): Additional note: there's a line-number counting bug in GHCi when multi- line input is involved independent of this patch; as you can see in the following example, GHCi seems to use a wrong line-number offset when evaluating multi-line input: {{{ λ> :set prompt "\955:%l> " λ:3> :set prompt2 ":%l| " λ:4> :{ :5| let x = () :6| :7| y = () :8| z = () :9| :10| x = () :11| :} <interactive>:11:5: Conflicting definitions for ‛x’ Bound at: <interactive>:11:5 <interactive>:16:5 λ:12> x <interactive>:12:1: Not in scope: ‛x’ λ:13> x <interactive>:13:1: Not in scope: ‛x’ λ:14> }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8047#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8047: Implement line-number %-substitution for prompt-string -------------------------------------+------------------------------------ Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.8.1 Component: GHCi | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): OK with me! Nice small patch! Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8047#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8047: Implement line-number %-substitution for prompt-string -------------------------------------+------------------------------------ Reporter: hvr | Owner: Type: feature request | Status: patch Priority: normal | Milestone: 7.8.1 Component: GHCi | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by hvr): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8047#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8047: Implement line-number %-substitution for prompt-string
-------------------------+-------------------------------------------------
Reporter: hvr | Owner: Herbert Valerio Riedel
Type: |

#8047: Implement line-number %-substitution for prompt-string -------------------------------------+------------------------------------ Reporter: hvr | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 7.8.1 Component: GHCi | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by hvr): * cc: hvr (added) * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8047#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC