“Ambiguous type variable in the constraint” error in rewrite rule