Skip to content

Instantly share code, notes, and snippets.

@rahulmutt
Last active June 30, 2018 03:17
Show Gist options
  • Save rahulmutt/46e0d27a32037de538a2a9b7a054c35b to your computer and use it in GitHub Desktop.
Save rahulmutt/46e0d27a32037de538a2a9b7a054c35b to your computer and use it in GitHub Desktop.
Eta IDE Support

Eta REPL already provides functionality for getting several bits of information about loaded source code, most of which is available after running :set +c.

  • :load will do a -O0 compilation of the specified file and directly load the class files into the underlying eta-serv's JVM process's heap.

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:load

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L1721-L1723

  • :reload will detect any changes and recompile accordingly and only reload the transitively changed modules.

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:reload

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L1802-L1807

  • :loc-at command will, given a source span, provide the original definition site of the identifier in the source span.

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:loc-at

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L2024-L2031

  • :all-types will provide source spans mapped to types indicated a particular subexpression has the given type.

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:all-types

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L2034-L2049

  • :type-at will provide a type given a source span

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:all-types

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L2003-L2011

  • :uses will provide all the uses of given source span in the current module

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:uses

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L2014-L2021

  • :info will provide information like the type and the definition (if it exists)

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:info

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L1423-L1431

  • :type will provide the type the provided expression

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:type

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L1993-L2000

  • :kind! will provide the kind of the reduce type

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:kind

Implementation: https://github.com/typelead/eta/blob/master/eta/Eta/REPL/UI.hs#L2124-L2128

  • :browse will list out all the exported functions/types of the given module

Documentation: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#ghci-cmd-:browse

The idea is to create a new server process called eta-ide which will be distributed with every Eta binary distribution and which provides all the facilities for IDE usage.

eta-ide will be a server that implements all the functionality mentioned above, but takes JSON input and returns JSON output.

This most likely means we should have a common library that provides the functionality (eta-ide-core) and have the Eta compiler/REPL + eta-ide depend on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment