• Why do pattern synonyms not cause type refinement? June 18, 2016

    Pattern synonyms can’t (safely) cause any additional type refinement than their definition dictates. This means that they can’t be used to provide a GADT-like interface when the underlying representation is not a GADT. The purpose of this note is to explain this restriction.

    Read more

  • Pattern Synonyms in GHC 8.0 December 12, 2015

    There have been four small but significant improvements to pattern synonyms which are going to appear in GHC 8.0.

    This work closes up some holes which were left in the implementation of pattern synonyms and should provide library authors with a new and flexible method of abstraction.

    More information about pattern synonyms can be found in the GHC 8.0 user guide.

    Read more

  • Automatically Apply HLint Suggestions November 22, 2015

    Users upgrading to hlint 1.9.23 will now be able to take advantage of the new --refactor flag which by invoking the refactor executable supplied by apply-refact can automatically apply suggestions.

    example
    Read more

  • Announcing ghc-exactprint: A New Foundation For Refactoring Tools July 23, 2015

    Over the last few months Alan Zimmerman and myself have been working on what will hopefully become a new foundation for refactoring Haskell programs. We have called this foundation ghc-exactprint and it is now available on hackage to coincide with the release of GHC 7.10.2.

    Thompson and Reinke originally described 22 refactorings in their catalogue of functional refactorings which motivated the development of HaRe. Missing from their list is the identity transformation, in the context of refactoring this is perhaps the most important. When applying any kind of change to small segment of your project it is undesirable for the tooling to modify another part of your file unexpectedly. The identity refactoring seems to be the easiest of all but it is important that any refactoring tool behaves in this way.

    The biggest challenge of the last few months was being able to perform the identity refactoring whilst retaining a suitable representation to be able to easily transform programs. Now that we believe that ghc-exactprint is robust, the challenge is to build the promised refactoring tools upon it.

    Read more

  • Data Types à la Carte with Closed Type Families December 20, 2014

    By hitting that critical sweet spot of solving an interesting problem and having a catchy name, most know, if not understand Wouter Swierstra’s data types à la carte.

    As the name suggests, the à la carte approach involves composing together data types to form bigger, custom types along with functions where we can precisely specify the necessary pieces. The approach relies heavily on a clever trick with type classes which is reviewed below. With more modern GHC extensions, the implementation can be made much more explicit, this is what this post will explore.

    For a general overview of the approach there is no better introduction than the original functional pearl.

    Read more