Add (unsafe) haskell implementation and tests.