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

GHC ghc-devs at haskell.org
Wed Jul 10 10:01:13 CEST 2013


#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



More information about the ghc-tickets mailing list