let wrap f x = try Ok (f x) with ex -> Bad ex