some infrastructure and define trivial rest cat and rest cat for partial functions implemented using Maybe