refactoring PapillonCore.hs