package lrgrep

  1. Overview
  2. Docs
Detailed error messages for Menhir-generated parsers

Install

dune-project
 Dependency

Authors

Maintainers

Sources

lrgrep-0.9.tbz
sha256=e53de12e4c5cbe6bca00643593266b4f9fa2e3f6a138195eeff7a4329f5c1c75
sha512=7fd7c4d11506fea7cc11c9bbf5aea9142d905643553c0c90e1bb16b794106b0c14a266acf89ae91b6929008dc0ba6515f788642873e2e4ba6c3d49bd45d25127

doc/fix/Fix/HashCons/index.html

Module Fix.HashConsSource

This module offers support for setting up a hash-consed data type, that is, a data type whose values carry unique integer identifiers.

Sourcetype 'data cell = private {
  1. id : int;
  2. data : 'data;
}

The type 'data cell describes a cell that carries a unique identifier id as well as a payload data.

This type is marked private, which means that the user has no direct way of allocating cells. Instead, the user must apply the functor Make (below) to obtain a function make which either allocates a fresh cell or returns an existing cell. The user is still allowed to read existing cells.

Sourceval id : 'data cell -> int

id cell returns the integer identifier of the cell cell.

Sourceval data : 'data cell -> 'data

data cell returns the payload of the cell cell.

Cells come with an equality test equal, a comparison function compare, and and a hash function hash. These functions exploit the cell's unique identifier only: the data is ignored.

As a result, wherever a module of signature HashedType with type t = foo cell is expected, the module HashCons can be supplied. This holds regardless of the type foo.

Sourceval equal : 'data cell -> 'data cell -> bool

equal determines whether two cells are the same cell. It is based on the cells' integer identifiers.

Sourceval compare : 'data cell -> 'data cell -> int

compare implements a total order on cells, It is based on the cells' integer identifiers.

Sourceval hash : 'data cell -> int

hash is a hash function on cells. It is based on the cells' integer identifiers.

Sourcemodule type SERVICE = sig ... end

A hash-consing service allocates uniquely-numbered cells for data. The smart constructor make either allocates a fresh cell or returns an existing cell, as appropriate.

Sourcemodule Make (M : sig ... end) : SERVICE with type data = M.key

The functor Make expects a type data for which a memoizer exists, and produces a hash-consing service for it.

Sourcemodule ForHashedType (T : sig ... end) : SERVICE with type data = T.t

ForHashedType is a special case of Make where it suffices to pass a hashed type T as an argument. A hash table is used to hold the memoization table.

Sourcemodule ForHashedTypeWeak (T : sig ... end) : SERVICE with type data = T.t

ForHashedTypeWeak is a special case of Make where it suffices to pass a hashed type T as an argument. A weak hash table is used to hold the memoization table.