anchor.diff:      : uenv
       -> string
       -> option<tc_result> =
  -    let some_cache_invalid = BU.mk_ref None in
  -    let invalidate_cache fn = some_cache_invalid := Some fn in
  -    let load env source_file cache_file =
  -        match load_value_from_cache cache_file with
  -        | Inr msg ->
  -            Inl msg
  -        | Inl (_, digest, _, _, tc_result) ->
  -            match hash_dependences
  -                  (TcEnv.dep_graph env)
  -                  source_file
  -                  cache_file
  -            with
  -            | Inr digest' ->
  -                if digest=digest'
  -                then Inr tc_result
  -                else begin
  -                if Options.debug_any()
  -                then begin
  -                    BU.print4 "Expected (%s) hashes:\n%s\n\nGot (%s) hashes:\n\t%s\n"
  -                            (BU.string_of_int (List.length digest'))
  -                            (FStar.Parser.Dep.print_digest digest')
  -                            (BU.string_of_int (List.length digest))
  -                            (FStar.Parser.Dep.print_digest digest);
  -                    if List.length digest = List.length digest'
  -                    then List.iter2
  -                        (fun (x,y) (x', y') ->
  -                        if x<>x' || y<>y'
  -                        then BU.print2 "Differ at: Expected %s\n Got %s\n"
  -                                        (FStar.Parser.Dep.print_digest [(x,y)])
  -                                        (FStar.Parser.Dep.print_digest [(x',y')]))
  -                        digest
  -                        digest'
  -                end;
  -                Inl "Stale"
  -                end
  -            | Inl msg -> Inl msg
  -
  -    in
       fun env fn ->
         let load_it () =
           let cache_file = Dep.cache_file_name fn in
           let fail msg cache_file =
  -          invalidate_cache();
             //Don't feel too bad if fn is the file on the command line
             if not (Options.should_verify_file fn) then
               FStar.Errors.log_issue
                 (Range.mk_range fn (Range.mk_pos 0 0) (Range.mk_pos 0 0))
                 (Errors.Warning_CachedFile,
                  BU.format3
  -                 "Unable to compute digest of %s since %s; will recheck %s and all subsequent files"
  +                 "Unable to load %s since %s; will recheck %s and all subsequent files"
                    cache_file msg fn)
           in
  -        match !some_cache_invalid with
  -        | Some _ -> None
  -        | _ ->
  -          if not (BU.file_exists cache_file) then begin
  -            fail (BU.format1 "file %s does not exists" cache_file) cache_file;
  -            None
  -          end
  -          else match load env.env_tcenv fn cache_file with
  -               | Inl msg ->
  -                 fail msg cache_file;
  -                 None
  -               | Inr res -> Some res
  +        load_checked_file_with_tc_result (TcEnv.dep_graph env.env_tcenv) fn cache_file;
  +        match BU.smap_try_find mcache cache_file with
  +        | Some (Invalid msg, _) -> fail msg cache_file; None
  +        | Some (Valid (_, tc_result), _) -> Some tc_result
  +        | _ -> failwith "load_checked_file_tc_result must have an Invalid or Valid entry"
         in
         Options.profile load_it (fun res ->
           let msg =
  
positive.code: (*
   * Abbreviation for what we store in the checked files
   *)
  type cache_t = int *  //cache version number
                 list<(string * string)> *  //digest of direct dependencies
                 string *  //digest of just this file
                 Parser.Dep.parsing_data * //parsing data for this file
                 tc_result  //typechecking result, including the smt encoding
  
  let mcache = 
  
  let load_value_from_cache :string -> either<cache_t, string> =
    let mcache = BU.smap_create 20 in
    let add_to_mcache_and_return cache_file v =
      BU.smap_add mcache cache_file v;
      v
    in
    fun cache_file ->
      let add_and_return = add_to_mcache_and_return cache_file in
      match BU.smap_try_find mcache cache_file with
      | Some x -> x
      | None ->
        match BU.load_value_from_file cache_file with
        | None -> Inr "Corrupt" |> add_and_return
        | Some cache_data ->
          let (vnum, _, _, _, _) = cache_data in
          if vnum <> cache_version_number
          then Inr "Stale, because inconsistent cache version" |> add_and_return
          else Inl cache_data |> add_and_return
  
  
  let store_value_to_cache (cache_file:string) (data:cache_t) :unit =
    BU.save_value_to_file cache_file data
  
  (*
   * Read parsing data from the checked file
   * This function is passed as a callback to Parser.Dep
   *)
  let load_parsing_data_from_cache file_name :option<Parser.Dep.parsing_data> =
    let cache_file =
      try
       Parser.Dep.cache_file_name file_name |> Some
      with _ -> None
    in
    if cache_file = None then None
    else match cache_file |> must |> load_value_from_cache with
         | Inr _ -> None
         | Inl (_, _, dig, pd, _) ->
           if dig <> BU.digest_of_file file_name then None else Some pd
  
  
  let hash_dependences deps fn cache_file =
    let fn =
      match FStar.Options.find_file fn with
      | Some fn -> fn
      | _ -> fn
    in
    let digest_of_file fn =
      if Options.debug_any()
      then BU.print2 "%s: contains digest of %s\n" cache_file fn;
      BU.digest_of_file fn
    in
    let module_name = Dep.lowercase_module_name fn in
    let source_hash = digest_of_file fn in
    let has_interface = Option.isSome (Dep.interface_of deps module_name) in
    let interface_hash =
      if Dep.is_implementation fn
      && has_interface
      then ["interface", digest_of_file (Option.get (Dep.interface_of deps module_name))]
      else []
    in
    let binary_deps = Dep.deps_of deps fn
  
negative.code: module NBE     = FStar.TypeChecker.NBE
  
  
  (*
   * We write this version number to the cache files, and
   * detect when loading the cache that the version number is same
   *)
  let cache_version_number = 9
  
  type tc_result = {
    checked_module: Syntax.modul; //persisted
  