Port bindist script to Haskell