buildable with ghc 7.6 and 7.8. added some type-signatures in local definition