[commit: ghc] wip/T10874: Merge new commands from ghci-ng (re #10874) (a473868)

git at git.haskell.org git at git.haskell.org
Sun Sep 13 15:15:19 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T10874
Link       : http://ghc.haskell.org/trac/ghc/changeset/a4738680ab35fb5d844609fc8755c46268ad6800/ghc

>---------------------------------------------------------------

commit a4738680ab35fb5d844609fc8755c46268ad6800
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sun Sep 13 13:19:13 2015 +0200

    Merge new commands from ghci-ng (re #10874)
    
    This was for the major part implemented by Chris Done on
    
     https://github.com/chrisdone/ghci-ng
    
    and has been in use by Emacs's `haskell-mode` for about a year already.
    
    I've squashed the commits, rebased to GHC HEAD, and cleaned up the patch.
    
    -----
    
    The new commands this commit adds are (description copied from [1]):
    
    * The `:set +c` command: collect information about modules after
      they've been loaded, and remember it between loads (including failed
      ones). I recommend adding this line to your `~/.ghci` file.
    
    * The `:type-at` command (requires `+c`): show the type at the given position in the
      module. Example:
    
      ``` haskell
      *X> :type-at X.hs 6 6 6 7 f
      Int -> Int
      ```
    
      This can be useful to get the type of a pattern variable or an
      arbitrary selected expression.
    
      The parameters are:
    
            <filename> <line> <col> <end-line> <end-col> <text>
    
      `text` is used for when the span is out of date, i.e. the file
      changed and the code has moved, text can be used to confirm the
      contents of the span matches, and to fallback to a general :t-like
      lookup.
    
    * The `:loc-at` command (requires `+c`): get the location of the thing at the given
      position in the module. Example:
    
      ``` haskell
      *X> :loc-at X.hs 6 14 6 16 mu
      X.hs:(8,7)-(8,9)
      ```
    
      This is useful for goto-definition features of editors and IDEs.
    
      Parameters are the same as for `:type-at`.
    
    * The `:uses` command (requires `+c`): gets all module-local uses of
      the thing at the given position in the module. Example:
    
      ``` haskell
      > :uses /home/chris/Projects/ghci-ng/ghc/GhciFind.hs 53 66 53 70 name
      /home/chris/Projects/ghci-ng/ghc/GhciFind.hs:(46,25)-(46,29)
      /home/chris/Projects/ghci-ng/ghc/GhciFind.hs:(47,37)-(47,41)
      /home/chris/Projects/ghci-ng/ghc/GhciFind.hs:(53,66)-(53,70)
      /home/chris/Projects/ghci-ng/ghc/GhciFind.hs:(57,62)-(57,66)
      ```
    
      This is useful for highlighting and navigating all uses of an
      identifier in editors and IDEs.
    
      Parameters are the same as for `:type-at`.
    
    * The `:all-types` command (requires `+c`): list *all* types in the project:
      expressions, bindings top-level and local. Sort of like `:browse` on
      steroids.
    
      ``` haskell
      > :all-types
      ghc/GhciTypes.hs:(38,13)-(38,24): Maybe Id
      ghc/GhciTypes.hs:(45,10)-(45,29): Outputable SpanInfo
      ghc/GhciTypes.hs:(45,10)-(45,29): (Rational -> SpanInfo -> SDoc) -> Outputable SpanInfo
      ```
    
    [1]: https://github.com/chrisdone/ghci-ng/blob/master/README.md


>---------------------------------------------------------------

a4738680ab35fb5d844609fc8755c46268ad6800
 ghc/GhciFind.hs      | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++
 ghc/GhciInfo.hs      | 156 +++++++++++++++++++++++++++++++
 ghc/GhciMonad.hs     |  18 ++++
 ghc/GhciTypes.hs     |  57 +++++++++++
 ghc/InteractiveUI.hs | 183 +++++++++++++++++++++++++++++++++++-
 ghc/ghc-bin.cabal.in |  13 ++-
 6 files changed, 680 insertions(+), 7 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a4738680ab35fb5d844609fc8755c46268ad6800


More information about the ghc-commits mailing list