posts `for_` publish

Open-Source Projects

Open-source projects created by me include:

brittany - see the github repo, also available on hackage.

Source-code formatting tool for haskell source code, more advanced than any previous alternatives. Properly tested and reliably working, but not yet considered finished in terms of functionality. Not all language extensions are supported yet, and only functions are reformatted. Given the large number of GHC extensions this should not be too surprising.

Being based on the ghc-exactprint library means that brittany makes use of the GHC parser. This has two advantages: Firstly supporting all existing and upcoming language extensions is seamlessly possible. Secondly, the “exact” in ghc-exactprint means that brittany can properly reproduce comments and newlines: brittany has a strong opinion on how to layout the haskell parts, but leaves any further formatting made by the programmer untouched.

In typical haskell manner, the brittany implementation involves several layers of “embedded DSL” (really, just specific monads) that help separate different concerns. Interested users should have a look at the dataflow documentation and the other documentation in the doc directory.

exference - see the source on github

Automatic code generation based on types, well tested and fully working. The name is a play on the term “type inference”, because exference uses the well-known Henry-Milner type-inference algorithm, only in reverse: It creates random expressions but incrementally checks that type-inference would produce the desired type.

In contrast to the similar utility djinn, exference supports a larger subset of the haskell type system; most notably it can handle queries containing constraints on type variables. The price is that exference can not promise termination.

Exference can serve two use-cases:

  1. Automatic code generation (especially in combination with ghc’s “typed-holes” feature) to fill in parts of your program that only have one possible/sensible implementation. Unfortunately, exference has a tight practical upper limit to the size of expressions it can generate, making it less useful for users who know already know the core libraries in the ecosystem very well;
  2. Enabling type-directed API searches. Prime example is the query for the base-library function that does the conversion Int -> Float. Existing search engines won’t find useful results, because the solutions have rather generic types, e.g. fromIntegral :: (Integral a, Num b) => a -> b

A more detailed description is available here.

General-purpose libraries