add haskell port

(This is more or less a direct port. A lot of these computations would likely be broken into smaller functions in idiomatic Haskell.)