let rec protect_map f = function
  | [] -> Result []
  | x::xs ->
      match f x with
        | Result y ->
            ( match protect_map f xs with
                | Result ys -> Result (y :: ys)
                | Warning _ as w -> w )
        | Warning(m,p) -> Warning(m,p)