lunes, 27 de junio de 2011

Cabal editor, HLint suggestions

The past week I've continued learning about Eclipse and integrating more Haskell tools in it. The final result is that now you can edit simple Cabal files graphically and run HLint on your code automatically. I'll add some screenshots of this:

The Overview page in the graphical Cabal editor has been renamed to Package and now contains almost all general information about a package that you can modify in a Cabal file. In particular, I've added support for a list of tested-with compilers, different build types and a tree to select if you want files from your project inside the data-files property, which you can later access programatically.

You can also configure your Haskell programs via the Executables page. From here, you can change the dependencies, the source directories and the module which will act as main. Extra options for GHC can also be provided from here.

Of course, the Dependencies part uses the information from the Haskell Browser to allow you to navigate through your list of installed packages and read the documentation for them.

The Library page is almost identical to the Executables one. The only important difference is that, instead of a Main list, you get a check-list of Exposed modules.
The main feature from Cabal which is not available here is the use of configuration flags. This is mostly due to the fact that I cannot come with a good user interface for that matter, and haven't found nothing in other similar projects.

The HLint integration is mostly invisible to the programmer until there is some suggestion, which will be shown in the editor and the Problems view as the rest of warnings from the compiler.

If you already have a Haskell project in EclipseFP and want to get this functionality, apart from installing the latest version of EclipseFP from GitHub, you need to add the HLint Builder to the list of builders that will be run automatically.

Last but not least, I spent one day making easier for the user to use the Haskell Browser. As with scion-server, now scion-browser comes bundled with the Eclipse plug-in, and is compiled and installed automatically.

domingo, 19 de junio de 2011

Some videos on Haskell Browser

As I said in the previous post on installing EclipseFP with support for Haskell Browser, I've made three videos showing some of the features I'm most proud of :) I recommend to look at them at fullscreen and change the quality to 720p, because the font size is small and the messages I've written in the editor may be lost.

Installing EclipseFP with Haskell Browser support [very experimental]

In this last week I've been integrating the work I've done in scion-browser into EclipseFP. This means that now you can browse the definitions inside your locally installed packages inside the environment, and also ask to the fabulous Hoogle for information.
However, I don't feel confident to ask for merging my changes into the main branch of EclipseFP yet. That's why I'm posting instructions on how to get an Eclipse with the Haskell Browser so everybody can check by their own and send suggestions and bugs (both of them are very welcome).
So, here are the instructions (they seem very long but I've tried to go step by step so people not used to Eclipse could follow them without problems):

  • Install Hoogle in you computer: just open a console and run "cabal install hoogle"
  • Hoogle needs some data to work which can be retrieved by running "hoogle data"
  • Get a copy of the scion-browser code by running "git clone git://"
  • Build it: "cd scion-class-browser && cabal configure && cabal build"
  • In the previous configure step Cabal may tell you that some prerequisites are not installed. If so, install them by running "cabal install <package-name>"
  • Download Eclipse. Any version would do, although my recommendation is to get the one for C/C++ developers, because it's a bit smaller than the others
  • Download EclipseFP 2011-06-19 archive
  • Extract the Eclipse archive you downloaded and run "eclipse" inside the folder that will be created. That is all the installation needed by Eclipse :)
  • Once you are in Eclipse (if you are new to it, the first time it will ask you for a workspace, which is the folder used to save configurations and projects), click Help > Install New Software...
  • In the window that will appear, click on the Add... button next to the Work with textbox
  • You will end into the Add Repository window. Click Archive... and select the EclipseFP 2011-06-19 archive you downloaded. Click OK afterwards
  • If you see the message There are no categorized items, uncheck the Group items by category checkbox
  • Check FP: Haskell support for Eclipse in the available items list and click Next
  • After pressing Next a couple of times more and saying yes to install unsigned software, Eclipse will ask you to restart. Do it
  • You will see the next window. Don't panic, it just tells you that we need to configure scion-browser
  • After clicking OK, the Scion server (the one providing compilation services to EclipseFP) will start compiling. I recommend you to wait until it finishes
  • Once it finished, click Window > Preferences... and navigate to Haskell > Scion, Cabal and Browser page
  • For the Browser executable, select the scion-browser you compiled before, which will be in <folder where you cloned the repository>/dist/build/scion-browser/scion-browser
  • Click the Open Perspective... button in the upper right corner, select Other... and in the Perspectives window, select Haskell or Haskell Browser
  • The next window asking to rebuild the database will be shown. If it doesn't, just close Eclipse and open it again. Of course, answer Yes to the dialog, so the information for the Browser is created

And that's all. When the rebuilding process finishes, you can start using the Browser perspective or the Hoogle view. More information about the features in the next post.

viernes, 17 de junio de 2011

A rapid screenshot

I'll do the usual summary of the week next Sunday, but I cannot resist to show what I just got into my screen. Finally scion-browser and Eclipse are working together and there is a first prototype of a Haskell Browser perspective. It still needs to show documentation comments and Hoogle integration, but it looks nice :)

lunes, 6 de junio de 2011

Week #2

This week I've been working in several independent tasks for the EclipseFP Browser, both in the Haskell backend and Eclipse frontend.

In the backend, I've tried to speed up a bit the creation of the databases. After some time looking for solutions and trying to build my own one using parallel package, I found the amazing parallel-io, which completely suited my needs. Now the user may use more than one thread for running Hackage and parsing the results back.

Although my initial thought was integrating the browser code directly inside Scion, it seems that library is in the middle of a process of rearchitecture. So my mentor suggested me to create a different executable for browsing tasks, and that was part of my work in the beginning of the week. Being used to the JSON libraries in the Java and Python world, aeson really alleviates a lot of work. The result is that now you can query an executable scion-browser for documentation about the installed packages in your system. The frontend is not very user-friendly, because it's oriented to be consumed by other tools such EclipseFP, but in any case you can consult the entire list of commands here.

The worst part this week has been my continuous fight against linking and Template Haskell-ing. For the console executable I started using editline, but when recompiling some file using Template Haskell, it made GHC crash. Fortunately, this is one of the times when Haskell has more than one library for the same task, and the problem was easily solvable using haskeline.

On the same line, when I was trying to integrate Hoogle, I got lots of problems about undefined references in Hoogle library. At first, they appeared in Template Haskell, so I decided to remove every use of that feature in my code. Thanks to the GHC option -ddump-splices, this was not as utterly boring at it seemed. However, when I finally got rid of that, the linker still showed me those kind of errors. It seems to be related to the fact that the hoogle package builds both a library and an executable and some object files are not correctly put in the archive. The solution for this problem was not using directly the library, but call the hoogle command for searches, and parse its output, which was easy as most of the parsing could be reused from the work in last week.

With all that, I felt it was time to start hacking in the Java side. Grasping all the concepts in Eclipse is taking some time, but I've been reading the great "Eclipse plug-ins" book and have more or less an idea on where to start hacking. Yesterday I used some time to create all the Java counterparts of module, package and declarations information, and the parsing and uparsing of JSON commands.

That's all. The next weeks I'll be working on the Browser in Eclipse. In the meantime, I'm also thinking about the best user interface for Cabal files editing, and I'm willing to hear any suggestion or comment in that topic :)