package ppx_hash

  1. Overview
  2. Docs
A ppx rewriter that generates hash functions from type expressions and definitions

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.0.tar.gz
sha256=8c8acae276a349d412eab9112cc3afa996d26ad4a01f2882121fc0adee0dd05e

doc/src/ppx_hash/ppx_hash.ml.html

Source file ppx_hash.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
open Ppxlib

let type_extension name f =
  Context_free.Rule.extension
    (Extension.declare
       name
       Core_type
       Ast_pattern.(ptyp __)
       (fun ~loc ~path:_ ty -> f ~loc ty))
;;

let () =
  let name = "hash_fold" in
  Deriving.ignore
    (Deriving.add name ~extension:(fun ~loc:_ ~path:_ ty ->
       Ppx_hash_expander.hash_fold_core_type ty));
  Driver.register_transformation
    name
    ~rules:[ type_extension name Ppx_hash_expander.hash_fold_type ]
;;

let () =
  let name = "hash" in
  Deriving.ignore
    (Deriving.add
       name
       ~str_type_decl:
         (Deriving.Generator.make_noarg
            Ppx_hash_expander.str_type_decl
            ~attributes:Ppx_hash_expander.str_attributes)
       ~sig_type_decl:(Deriving.Generator.make_noarg Ppx_hash_expander.sig_type_decl)
       ~extension:(fun ~loc:_ ~path:_ ty -> Ppx_hash_expander.hash_core_type ty));
  Driver.register_transformation
    name
    ~rules:[ type_extension name Ppx_hash_expander.hash_type ]
;;
OCaml

Innovation. Community. Security.