let pkgcheck callback solver failed tested id =
  let memo (tested,failed) res = 
    match res with
    |Success(f_int) -> begin
        List.iter (fun i -> Array.unsafe_set tested i true) (f_int ());
        Diagnostic_int.Success(fun ?all () -> f_int ())
    end
    |Failure r -> begin
        incr failed;
        Diagnostic_int.Failure(r)
    end
  in
  let req = Diagnostic_int.Sng id in
  let res =
    Util.Progress.progress progressbar_univcheck;
    if not(tested.(id)) then begin
      memo (tested,failed) (solve solver req)
    end
    else begin
      (* this branch is true only if the package was previously
       * added to the tested packages and therefore it is installable *)

      (* if all = true then the solver is called again to provide the list
       * of installed packages despite the fact the the package was already
       * tested. This is done to provide one installation set for each package
       * in the universe *)

      let f ?(all=false) () =
        if all then begin
          match solve solver req with
          |Success(f_int) -> List.map solver.map#inttovar (f_int ())
          |Failure _ -> assert false (* impossible *)
        end else []
      in Diagnostic_int.Success(f) 
    end
  in
  match callback with
  |None -> ()
  |Some f -> f (res,req)