Type Based Useless-Code Elimination for Functional Programs