Build_path_prefix_map(3)

✨ NAME ✨

Build_path_prefix_map β€” rewrite paths for reproducible builds, periodt. This is the Build_path_prefix_map(3) page from the OCaml library, and yes bestie, we're getting into some compiler-adjacent path magic πŸͺ„πŸ’…

🧩 Module

Module Build_path_prefix_map : sig end

Rewrite paths for reproducible builds β€” that's the whole vibe, no cap. 🌈

πŸ’– Documentation πŸ’–

⚠️ Warning: this module is unstable and part of Compiler_libs.

See the BUILD_PATH_PREFIX_MAP spec. πŸ“œ

Here's the exact signature, bestie β€” every type and val, untouched:

type path = string

type path_prefix = string

type error_message = string

val encode_prefix : path_prefix -> string

val decode_prefix : string -> (path_prefix, error_message) result

type pair = {
 target : path_prefix ;
 source : path_prefix ;
 }

val encode_pair : pair -> string

val decode_pair : string -> (pair, error_message) result

type map = pair option list

val encode_map : map -> string

val decode_map : string -> (map, error_message) result

val rewrite_first : map -> path -> path option

val rewrite_all : map -> path -> path list

val rewrite : map -> path -> path

val invert_all : map -> path -> path list

The encode/decode crew is encode_prefix, decode_prefix, encode_pair, decode_pair, encode_map, and decode_map β€” they're all right there in the signature above, shining like the little icons they are πŸŽ€


  • rewrite_first β€” rewrite_first map path tries to find a source in map that is a prefix of the input path. If it succeeds, it replaces this prefix with the corresponding target. If it fails, it just returns None. ✨
  • rewrite_all β€” rewrite_all map path finds all sources in map that are a prefix of the input path. For each matching source, in priority order, it replaces this prefix with the corresponding target and adds the result to the returned list. If there are no matches, it just returns []. πŸ’…
  • rewrite β€” rewrite uses rewrite_first to try to find a mapping for path. If found, it returns that; otherwise it just returns path. 🫢
  • invert_all β€” invert_all map path finds all targets in map that are a prefix of the input path. For each matching target, in priority order, it replaces this prefix with the corresponding source and adds the result to the returned list. If there are no matches, it just returns []. πŸ¦‹

That's the whole page, bestie. This lil' manual moment was brought to you by OCamldoc on 2026-06-22 for Build_path_prefix_map(3). Go make those builds reproducible, you icon πŸ‘‘πŸ’–

πŸ“¦ where this page comes from