domingo, 24 de agosto de 2014

Using Emacs for Haskell development

In the last months, the toolchain for using Haskell within Emacs has changed a lot, and has become a lot better. Apart from my additions to ghc-mod, new autocompletion packages such as company-ghc have appeared.

In the past, I've felt that there was a need for a comprehensive article of all the available options for Haskell development in Emacs, including haskell-mode, ghc-mod, company-ghc, HaRe and structured-haskell-mode. To fill this gap, I have written a tutorial covering installation, configuration and use of these tools, especially keeping an eye into making all of them work nicely when put together.

Hope it helps!

Summer of Code on Emacs!

This summer I've been participating in Google Summer of Code, as I did some years ago. My aim was the same: to make it easier for Haskell developers to interact with their code. But instead of Eclipse, I've focused on another very well-known editor: Emacs. In particular, I've been extending the already excellent ghc-mod.

During the last year I've turned increasingly jealous of the Emacs modes for Agda and Idris, two programming languages which resemble Haskell but add dependent types to the mix. Using those modes, you can work interactively with your code, write pattern matches automatically, refine certain parts of your code, ask the compiler what is the type that a certain code should have, and so on. Furthermore, since version 7.8 GHC includes support for typed holes, so it seemed like all the necessary infrastructure from the compiler was in place to do this.

Instead of a boring description of the outcome of the project, I have prepared a video demostration ;)

As a summary, here is the list of new key bindings that you can use since the release (just a few days ago) of ghc-mod 5.0:

  • C-u M-t: create the skeleton of a function from its signature, or the skeleton of a type class instance from its declaration,
  • M-t: perform case splitting on variables;
  • C-c M-n and C-c M-p: navigate between typed holes in your program, to the next or the previous one, respectively;
  • C-c C-f: refine a hole through an expression, including as much holes as needed to make it type check;
  • C-c C-a: try automatic completion of a hole by calling Djinn.

I would like to thank eveybody who has helped me during this summer, especially my mentor David Raymond Christiansen (whose work in idris-mode is just amazing) and Kazu Yamamoto, the creator and maintainer of ghc-mod.

domingo, 20 de noviembre de 2011

Moving to Persistent

I haven't said much in a while, but of course, things are moving in the EclipseFP world. JPMoresmau announced the 2.20 release of EclipseFP, which in terms of interface gives you a way to manage your local installation of Cabal packages and a better outline of Cabal files. Internally, a lot has changed, as EclipseFP moved from using Scion as backend to BuildWrapper. This big change will hopefully solve most of the memory problems that EclipseFP was experiencing.

Also, I would like to announce that scion-browser is moving from a in-memory database to using SQLite to back up the data. In my tests performance is comparable to the old one (although for big tasks as browsing the entire list of local modules is a bit slower), but doesn't need a big pile of memory to hold the entire database, which I think it's a big win. If you're curious, you can browse the code, but be warned it doesn't work with the current version of EclipseFP.

The change has been possible thanks to the incredible Persistent package of Yesod fame. With that, I hadn't had to write a single line of code to create the database or to insert data. The only problem has been that Persistent doesn't have any way to encode queries with multiples joins. This lead me to write some of the queries by hand (and to refresh my ancient knowledge of SQL).

Hope you like it. As usual, every suggestion to improve EclipseFP or scion-browser is more than welcome :)

viernes, 2 de septiembre de 2011

EclipseFP 2.1.0 released!

As JP Moresmau points in this blog entry, a new release of EclipseFP is out! It includes bug fixes and new functionality, including my work during the Summer of Code.

These past days JP has been working very hard to fix some bugs my code had, and added support for Unicode characters in Scion Browser (which means that you can browse base-unicode-symbols, for example), so I'm really grateful to him.

Apart from that, the new EclipseFP website is out and contains information about how to install this plug-in your system. If you find any bug, don't forget to tell us so we can improve EclipseFP as much as possible!

As a final note, next Monday 5 of September I'll be speaking about EclipseFP in the beautiful city of A Coruña, in Spain, during the Taller de Programación Funcional.

lunes, 22 de agosto de 2011

End of the summer

The Summer of Code has come to its end. It has been three wonderful months, in which I've learnt and hacked a lot. I hope the improvements to EclipseFP will be used and have made it a useful tool for all the Haskell programmers out there :D

One of the tasks I've also done during the summer is building a new webpage for EclipseFP. You can find it in http://eclipsefp.github.com/. In the next days, a new release of EclipseFP with all the changes I've done though the summer will be made available.

I cannot end my summer whithout thanking my mentor, Thomas Schilling, who has been responsive and helped me a lot with the Haskell coding; and JP Moresmau, the current EclipseFP maintainer, who helped me in my first steps diving into the Eclipse Platform. I also have a debt with A O Van Emmenis and Chris Done for the discussions we had about IDEs and Haskell during the last CamHac and the pile of suggestions they gave me.

I hope you have enjoyed the show, and I'll be delighted of hearing how people used EclipseFP, and willing to implemented more features during the next months.


Quick Assist and new builders

This last week of GSoC has been really productive in terms of user interface additions. Apart from completion, which I showed a couple of days ago, EclipseFP now has quick assist support. Quick assist means that for some kinds of errors, a small light bulb is shown in the left side of the editor. When you click it, ways to correct the error are suggested, and if you click on it, automatically applied.


Most of these fixes were already implemented by JP Moresmau, like adding a package to the Cabal file, removing redundant imports or adding a Language pragma to the file. My work in those has been to make them more discoverable and available through the light bulb icon. Apart from those, you will get the ability to add an import for a function that is not found (it even works if you qualify the item, making the new import qualified).

The rest of the work I want to present today was done between CamHac and the end of the last week. I've always felt that Haskell programming was not only writing Haskell code, but also writing code in tools like Alex, Happy or the UU Attribute Grammar system. Those tools allow you to express some constructions better and more concisely, and I thought that it would be nice to have them in EclipseFP.
So now you have syntax higlighting and automatic building of those files.


Last year I was studying at Utrecht University and really liked their Attribute Grammar System. The tool has a lot of options, and now you can configure them inside EclipseFP. Even more, the configuration is saved in the same format that the one used in uuagc-cabal package.


This has been all for the summer. A new EclipseFP release with all the features should be available very soon :D

miércoles, 17 de agosto de 2011

Autocompletion and more

In the past week I've continued adding features to EclipseFP. For example, now you can edit Alex, Happy or UUAGC files directly in EclipseFP, and you will get syntax highlighting (taking into accounts which zones are Haskell code and which others are non-Haskell). Last weekend I've attend CamHac. That was a wonderful experience to know new people, and also to collect suggestions and improvements for the plug-in. Two of those suggestions have already been implemented.
The first one is a tighter integration with some of the web frameworks available in Haskell-land. In particular, you can create Snap and Yesod projects directly from the New Project wizard in Eclipse, provided the neccessary tools are installed. Also, I've linked some content-types to existing web editors, so you will get HTML editor for a Heist template, CSS editor for a Lucius template and so on.
The other feature that most of the people requested was autocompletion. I didn't implement that before because my knowledge of both Eclipse and Scion was lower, and didn't really know where to start. But after these 3 months I've been able to come to a solution to the problem, and I'm delighted to present the new revamped Haskell code assist for EclipseFP:


In the following days I plan to implement more of the suggestions in my TODO list :D