Replacing FileType enum with a higher order function