Things I Read This Week, Pt. 2

4 Aug 2014

Actually I wanted to make a new post for this series every week, but I've been pretty busy working full-time at JetBrains on Scala plugin and spending my free time on Purescript Express.js bindings and Coursera assignments. So this is actually what I've been reading over the last month.

Phantom types for extra safety in Haskell

Part 1 Part 2

Great articles about interesting technique of taking some errors down to compile time. Though I prefer GADTs approach, Phantom types are pretty cool too.

Type classes: confluence, coherence and global uniqueness


This post is about surprising behaviour of GHC when resolving type-class constraints: though it requires for type-class instances to be non-overlapping, it doesn't check this constraint eagerly (it may increase compile time). Thus if you have different instances of a type-class in different modules you can accidentally write a program that will use both of this instances simultaneously. And if one of these instances has been kept by mistake (e.g. forgot to delete old code) this can lead to strange runtime errors which would be not so easy to locate. That's why this is a "must-know" thing for every haskeller.

GHC plans for 7.10.1 (+ 7.8.3 is out)

Reddit discussion

Seems like with kind cohersion and equality Haskell dives deeper into dependent types. And finally Applicative will become a superclass of Monad :)

Rust for functional programmers


Rust is definitely interesting language that caught my attention some time ago, but due to its instability and constant changes in API and syntax I've decided to wait and see where it'll come. The presence of articles like this shows that Rust is moving towards things I appreciate most in modern programming: explicit mutability, higher-order fns, algebraic datatypes, etc. Paired with C-like performance it should make a great language.

This article covers a lot of Rust syntax compared to OCaml and Haskell examples achieving the same things. Plus it has an explanation of Rust's sophisticated memory model. I hope by the time I'll finally decide to dive deeper in Rust this article will help a lot.

Mutable algorithms in immutable languages

Part 1 Part 2 Part 3

In this series of posts author implements ST monad step by step. In the 1st part we build abstract interface of monad that'll create and manage mutable references. The 2nd part brings us implementations of this interface based on IO monad and on Int map. The 3rd part fixes some locality breaches in previous implementations using Rank-N-Types and Phantom types (hi there!) and introduces ST-based implementation. Overall, these posts cover a lot of interesting ideas and useful techniques applicable in functional programming.