atom-haskell / ide-haskell

Haskell IDE plugin for Atom editor

Home Page:https://atom.io/packages/ide-haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Profiteur

varosi opened this issue · comments

This is a proposition only.

It'll be convenient if Atom has support for viewing of .prof files that come from GHC after profiling. The good news is that Profiteur tool is generating HTML files. I hope this is easy to visualize in Atom.

https://jaspervdj.be/posts/2014-02-25-profiteur-ghc-prof-visualiser.html

By far the easiest way to implement support for Profiteur is to build it with ghcjs and make an Atom package to wrap around that. There are two problems with this approach:

  1. Profiteur lacks library definitions. So to use it as a library, a fork would be needed.
  2. There's quite a lot of standalone javascript, which would need to be adapted to work with Atom.

Embedding a browser in Atom is doable, but error-prone and a bit of an overkill, frankly.

/cc @jaspervdj -- this would be a lot easier if you handled (1). If not, I might make a pull request at some point, but that would probably happen "blizzard-soon" (as in, only gods know when)

I can make profiteur available as a library but adapting the JavaScript code sounds like a lot of work -- definitely not worth the effort. Can atom not shell out to profiteur to generate something in /tmp and then open the resulting HTML page in the user's default browser? profiteur was designed to only generate a single HTML file with embedded assets to make this easier.

@jaspervdj, it is certainly possible, but there are a couple reasons to avoid that.

First, I'd prefer to avoid shelling out to Haskell binary if it can be avoided. Based on experience maintaining ide-haskell, users can run into a lot of problems in "installing binary dependencies" department. Bundling profiteur with the package would probably be an overall better user experience, but bundling a binary is not an option due to mutli-platform support -- hence ghcjs.

Second, it seems more than a bit counter-intuitive to open something in an external program (like browser or whatever) when you do have a javascript-enabled rich editor at hand.

That said, after a bit of snooping around Electron documentation, I think it should be possible to leave profiteur's js assets untouched, provided I manage to encapsulate its output in a webview (which should be relatively simple), so that solves the second problem. As for the first one, now that I think about it, a way of embedding data-files into ghcjs-produced executable is needed.

So, to recap, if there's a library, and if assets are embedded (e.g. with something like file-embed), it should be possible to straight up write an Atom package with no external dependencies and little effort.

I suddenly got a free day to myself, so I slapped together a prototype. Code quality could be better, but it seems to work pretty much as I expect it to. https://atom.io/packages/ide-haskell-profiteurjs

Associated changes: jaspervdj/profiteur#7

Cool! I'll try it!