Git Product home page Git Product logo

ghci-ng's Introduction

ghci-ng - Next generation GHCi

This is GHCi plus extra goodies. It is a direct codebase copy from the GHC codebase of GHCi with modifications to be buildable as a Hackage package.

Features

The features additional to normal GHCi function in the latest GHC (7.8.3) release are:

  • 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:

    *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:

    *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 :all-types command (requires +c): list all types in the project: expressions, bindings top-level and local. Sort of like :browse on steroids.

    > :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

Columns start at 1 instead of zero, because this is how GHC now outputs its column numbers.

Installing

From source:

$ git clone [email protected]:chrisdone/ghci-ng.git
$ cabal install ghci-ng/

This version is not available on Hackage yet.

(Hackage flat out rejects the -dynamic flag which is required for GHCi to work properly.)

Check it

It should say GHCi-ng on the welcome message:

$ ghci-ng
GHCi-ng, version 7.8.2 [NG/0.0]: http://www.haskell.org/ghc/  :? for help

You're now using the next generation GHCi!

Using with cabal repl

Run cabal repl in the following way:

$ cabal repl --with-ghc=ghci-ng

Using with haskell-mode

Using with haskell-mode is very easy, it's a drop-in replacement for the normal use of GHCi.

If you use the cabal-repl process type, use:

(setq haskell-process-args-cabal-repl
      '("--ghc-option=-ferror-spans" "--with-ghc=ghci-ng"))

Plain GHCi process type:

(setq haskell-process-path-ghci "ghci-ng")

Commands that use GHCi-ng:

  • M-x haskell-mode-show-type-at
  • M-x haskell-mode-goto-loc

Recommended bindings:

(define-key interactive-haskell-mode-map (kbd "M-.") 'haskell-mode-goto-loc)
(define-key interactive-haskell-mode-map (kbd "C-c C-t") 'haskell-mode-show-type-at)

Make sure to run :set +c in GHCi to enable collection of info, then load some modules and the above commands will work.

Use with Vim

Patches welcome.

Use with SublimeText

Patches welcome.

Supported GHC versions

This project should ideally support the current major GHC version and the past major GHC version:

ghci-ng's People

Contributors

chrisdone avatar iand675 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.