package asak

  1. Overview
  2. Docs
type threshold =
  1. | Percent of int
    (*

    A percentage threshold, a number between 0 and 100.

    *)
  2. | Hard of int
    (*

    A hard threshold.

    *)
type config = {
  1. should_sort : bool;
    (*

    If we sort all lists of hashes. This is useful to identify more codes, but can identify unfactorizable code.

    *)
  2. hash_var : bool;
    (*

    If we hash names in the AST.

    *)
}
type fingerprint = int * Digest.t

A fingerprint is a weighted Digest.t

type hash = fingerprint * fingerprint list

A type synonym for the result of the hash_lambda function

val hash_lambda : config -> threshold -> Lambda.lambda -> hash

Hash a lambda expression. Usage: hash_lambda config threshold expr. Two lambda expressions "of the same shape" will share the same hash. Particularly, constant are ignored.

  • parameter config

    A configuration for the function.

  • parameter threshold

    Used to decide which sub-AST hash is kept.

  • parameter expr

    The expression.

  • returns

    A tuple with the main hash, and a list of hashes of sub-ASTs satisfying the threshold.

Utilities

val map_snd : ('a -> 'b) -> ('c * 'a) list -> ('c * 'b) list
val hash_all : config -> int -> ('a * Lambda.lambda) list -> ('a * hash) list

Using a hard threshold, hash a list of lambda expressions from Parse_structure.read_structure.

val escape_hash : hash -> hash

Escape hashses for printing.