I've tidied it up and added some comments explaining what it does. The only dependency outside libraries which come with GHC is the 'text' package, which is included in the Haskell Platform.