Wip haskell rewrite