Scion is a Haskell library that aims to provide Haskell source code inspection and transformation functionality as well as various other features that may be useful for an IDE.
Most of Scion's functionality is based on the GHC API. Scion tries to be front-end agnostic; it provides both a Haskell API and servers for non-Haskell clients such as Emacs (no Vim, volunteers required).
(For developer builds see section "Hacking" below.)
$ cd dir/to/scion $ cabal install
Scion supports various configuration flags which are useful when working on Scion itself.
Since Scion is a library, you should consult the haddock documentation for how to use it. However, you may look at the Emacs frontend for inspiration.
The Emacs frontend is implemented as a Haskell server
Install Scion with Emacs support, either via
$ cabal install scion -femacs
or, if you have a locally copy of Scion
$ cd <scion> $ cabal install -femacs
You'll end up with a binary called "emacs-server".
Add the following to your emacs configuration (typically "~/.emacs"):
(add-to-list 'load-path "<scion>/emacs") (require 'scion) ;; if ./cabal/bin is not in your $PATH (setq scion-program "~/.cabal/bin/emacs_server") (defun my-haskell-hook () ;; Whenever we open a file in Haskell mode, also activate Scion (scion-mode 1) ;; Whenever a file is saved, immediately type check it and ;; highlight errors/warnings in the source. (scion-flycheck-on-save 1)) (add-hook 'haskell-mode-hook 'my-haskell-hook)
Scion mode needs to communicate with the external server. By default it will automatically start the server when needed. See "Manually Connecting to Scion" below for how to connect to the server manually.
The scion server process inherits the environment variables from the
Emacs process. Depending on your system this may be different than
what you'd get if you started the server from the shell. To adjust
PATH environment variable from within Emacs, add something like
the following to your
;; add ~/usr/bin to the PATH (setenv "PATH" "$HOME/usr/bin:$PATH" t)
Once you have a running and connected Scion server, you can use the commands provided by scion-mode:
C-c C-x C-l(
scion-load) load the current file with Scion. If the file is within a Cabal project this will prompt to use the settings from one of the components in the package description file. You can still choose to load only the current file using the default settings.
scion-open-cabal-project) configures a Cabal project and loads the meta-data from a Cabal file. Note that this does not type check or load anything. If you change the Cabal file of a project, call this function to update the session with the new settings.
If loading generates any errors or warnings, a buffer will appear and
list them all. Pressing
RET on a note will jump to its source
q closes the buffer, and
scion-list-compiler-notes) brings it back. Use
scion-previous-note-in-buffer) to navigate within the notes of one
There are a few more utilities:
C-c i l -- insert language pragma C-c i p -- insert pragma C-c i m -- insert (external) module name C-c i f -- insert command line flag
Some experimental features:
C-c C-t -- show type of identifier at point (currently only works on ids, not expressions)
Manually Connecting to Scion
If you set the variable
'ask (the default is
'always), Scion will ask whether to start the server. If you set it
nil you need to manually connect to the server.
You can start the server manually on the command line and then use
to connect to that server. However, most of the time it will be more convenient to start the server from within Emacs:
Please send bug reports or feature requests to the Issue tracker.
For discussions about Scion use the scion-lib-devel mailing list.
The main repository for Scion is hosted on Github. Get it via
$ git clone git://github.com/nominolo/scion
Send patches or pull requests to nominolo (email address at googlemail dot com). Note that, if you fork the project on Github your fork won't take up additional space on your account.
For development it is probably easier to use the GNU make than Cabal
directly. The makefile includes a file called
config.mk which is
not present by default. You can use the provided
and edit it:
$ cp config.mk.sample config.mk $ edit config.mk
After that, the makefile takes care of the rest.
$ make # configure and build $ make install # configure, build, and install
If you don't have the dependencies, yet, and have
following may be helpful (If it's not in the path, adjust
$ make cabal-install
(This also installs Scion, but that shouldn't interfere with hacking.)
Using an in-place GHC
GHC 6.10.1 has a couple of problems. For example, not all error
messages are reported using the GHC API but instead are printed to
stdout/stderr. Some parts also call
exitWith directly. GHC's HEAD
branch has some of these bugs fixed and may contain new features not
present in the stable branch. If you want to compile against an
inplace GHC, the following steps should work:
On windows, make sure that Cabal finds the inplace gcc
$ cd /path/to/ghc $ cp `which gcc` ghc/
(Adjust to version of GCC that GHC was compiled with.)
GHC_PATHvariable to the correct path to for your system. Make sure not to set
HADDOCK, they will automatically be set to point to the inplace versions.
make cabal-installas above.