Merged haskeline patch from John Wiegley

(merged by hand because it was submitted to a repository with different history)