Copy from https://github.com/ajhc/ajhc/issues/34.