---
name: "Build_path_prefix_map"
section: "3o"
platform: "linux"
package: "ocaml"
version: "5.5.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Build_path_prefix_map"
---

# Build\_path\_prefix\_map(3o)

Rewrite paths for reproducible builds

## NAME

Build\_path\_prefix\_map - Rewrite paths for reproducible builds

## Module

Module   Build\_path\_prefix\_map

## Documentation

Module **Build\_path\_prefix\_map**\
  :  **sig end**

Rewrite paths for reproducible builds

Warning: this module is unstable and part of **Compiler\_libs** .

See the BUILD\_PATH\_PREFIX\_MAP spec

*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**

**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** .

*val rewrite\_all* :  **map -\>** **path -\> path list**

**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  **\[\]** .

*val rewrite* :  **map -\>** **path -\> path**

**rewrite path** uses  **rewrite\_first** to try to find a mapping for path. If found, it returns that, otherwise it just returns  **path** .

*val invert\_all* :  **map -\>** **path -\> path list**

**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  **\[\]** .
