[GHC] #8305: ghci macros override built-ins for command expansion

GHC ghc-devs at haskell.org
Mon Sep 16 17:17:28 CEST 2013


#8305: ghci macros override built-ins for command expansion
-------------------------------------+------------------------------------
        Reporter:  rwbarton          |            Owner:
            Type:  bug               |           Status:  new
        Priority:  highest           |        Milestone:  7.8.1
       Component:  GHCi              |          Version:  7.7
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:  #8113
-------------------------------------+------------------------------------

Comment (by rwbarton):

 With the caveat that if we "expand to built-in" and there is a macro of
 the same name, we use the macro instead. But this makes it all sound more
 confusing than it really is.

 I imagine two stages in the interpretation of a ghci command: first name
 completion (`String -> String`), then name resolution (`String -> Maybe
 (Either UserMacro BuiltinCommand)`). I want the name completion to work
 exactly as in every previous released version of ghci: `:t` always means
 the same thing as `:type` unless the user has a macro named specifically
 `:t`. This is important so that anyone who's not using the new ability to
 override built-ins has an unchanged ghci experience. The name resolution
 step now prefers macros over built-ins, to allow the user (or a tool like
 cabal sandboxes) to override the meaning of built-in commands.

 The #8113 patch implements the desired new name resolution behavior, but
 it changes the name completion behavior at the same time.

 Here are some example scenarios.

 1. User has a macro `:time`, and enters `:t 3`.
 * ''ghci 7.6 behavior'' `:type 3`
 * ''current HEAD behavior'' `:time 3`
 * ''my desired behavior'' `:type 3`, like ghci 7.6

 2. User has a macro `:type`, and enters `:t 3`.
 * ''ghci 7.6 behavior'' `:type 3`, with the built-in `:type` (built-ins
 can't be overridden in 7.6)
 * ''current HEAD behavior'' `:type 3`, with the user's `:type` macro
 * ''my desired behavior'' `:type 3`, with the user's `:type` macro, like
 current HEAD

 2. User has a macro `:time` and also a macro `:type`, and enters `:t 3`.
 * ''ghci 7.6 behavior'' `:type 3`, with the built-in `:type`
 * ''current HEAD behavior'' `:time 3`
 * ''my desired behavior'' `:type 3`, with the user's `:type` macro;
 different from both 7.6 and HEAD

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8305#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list