jon.recoil.org

Source file ppx_hash_lib.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Std = struct
  module Hash = Hash
end

(** The functor is exposed to make it possible to use ppx_hash with alternative hash types
    without having to duplicate these definitions. *)
module F (Types : sig
    type hash_state
    type hash_value
  end) =
struct
  open Types

  type ('a : any) hash_fold = hash_state -> 'a -> hash_state

  module Hashable = struct
    module type S = sig
      type t : any

      val hash_fold_t : t hash_fold
      val hash : t -> hash_value
    end

    module type S1 = sig
      type 'a t : any

      val hash_fold_t : 'a hash_fold -> 'a t hash_fold
    end

    module type S2 = sig
      type ('a, 'b) t : any

      val hash_fold_t : 'a hash_fold -> 'b hash_fold -> ('a, 'b) t hash_fold
    end

    module type S3 = sig
      type ('a, 'b, 'c) t : any

      val hash_fold_t
        :  'a hash_fold
        -> 'b hash_fold
        -> 'c hash_fold
        -> ('a, 'b, 'c) t hash_fold
    end
  end
end

include F (struct
    type nonrec hash_state = Std.Hash.state
    type nonrec hash_value = Std.Hash.hash_value
  end)