Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PureScript GSOC proposal

Harry Garrood

GSOC proposal: Pursuit enhancements

PureScript is a language similar to (and written in) Haskell, which compiles to JavaScript. Due to PureScript's expressive type system, functions and data can provide lots of information and even guarantees about their structure and behaviour, through just their type signatures. For example, types can capture information such as not having any side effects, possibility of modifying the DOM, possibility of returning null, and so on.

The expressiveness of the type system means that a tool which can search for functions or data by type can be very useful. Haskell already has this, in the form of Hoogle. For example, if I forget how to get the integer code point for a Unicode character, I can just search for Char -> Int, and get ord. If I want to split a list into two lists based on a predicate, I can search for (a -> Bool) -> [a] -> ([a], [a]) and get partition.

Hoogle is frequently cited by Haskellers as an extremely valuable tool, and one that is sorely missed in languages that either don't have an equivalent, or would not be able to create one (as a result of insufficiently expressive type systems). Therefore, I think that a similar tool for PureScript would be extremely valuable for making PureScript easier to use, and could provide benefits for users with almost any experience level.

Currently there exists a tool called Pursuit, but it is quite primitive. It can only search by function or data names, not types, and it has no way of ranking search results by relevance. Part of my proposal is to work on Pursuit to make its searching more useful: this means enabling fuzzy searching for type and value names, as well as type searching.

Given the similarity of the type systems of Haskell and PureScript, I expect that I will be able to use work already done in this area -- that is, the algorithms that Hoogle uses -- which I now have a basic understanding of, having read the information about them on Neil Mitchell's website. I hope that I will also be able to reuse some of its code and possibly contribute to it too. However, since Hoogle was built for Haskell, it does not have knowledge of PureScript's effect types and row types, so I expect that I will implement that myself: either by building a separate layer to mediate between the Pursuit frontend and a Hoogle instance on the backend, or by including parts of Hoogle as a library into the main Pursuit server.

PureScript also suffers, currently, from not having a real centralized home for API documentation, like Hackage for Haskell code. Phil Freeman (the creator of PureScript) and I have discussed expanding Pursuit to serve this capability too, so that generated HTML documentation is available to read on the web, with correct links between types and functions in separate packages. This would involve:

  • modifying the documentation generator to give more control to the author about how the documentation appears: in what order, with what headings, and so on;
  • for exported values which have not been annotated with a type signature, possibly modifying the PureScript compiler so that it can generate better names for inferred types (for example, by making use of aliases where appropriate, by using information about what modules are imported and how, and so on) - this would be very nice to have, as it could improve type errors from the compiler itself as well;
  • one very exciting possibility is for interactive examples: since PureScript targets JavaScript, it should be feasible to allow users to fire up a REPL and play with things immediately inside their browser. PureScript already has Try PureScript, a compiler-as-a-service, but it currently has no concept of PureScript packages, so this will be nontrivial.

I believe I am well equipped to execute this project, given that I am already quite familiar with Haskell, PureScript, and Pursuit itself. I've already contributed a significant amount of code to both PureScript and Pursuit. In fact, I am currently the top contributor on Pursuit, according to GitHub. I also wrote one of the projects featured on PureScript's projects page -- a multiplayer pacman game, which involves a server and a client, both in PureScript (the server runs on Node.js). I am interested in Computer Science theory -- I study Mathematics at university, and take elective Computer Science courses, and I ported Haskell's Data.Sequence to PureScript, motivated by the poor asymptotic complexity of using native JavaScript arrays in PureScript -- which I expect will be useful for understanding (and implementing, if need be) the algorithms involved in name search and type search.

I also have over two years of experience at two separate companies as a full time software developer. My CV and further details of some of my other open source development experience can be found on my personal website:

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