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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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_any = sig
      type t : any

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

    module type S1_any = sig
      type 'a t : any

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

    module type S2_any = 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_any = 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

    module type S = sig
      type t

      include S_any with type t := t
    end

    module type S1 = sig
      type 'a t

      include S1_any with type 'a t := 'a t
    end

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

      include S2_any with type ('a, 'b) t := ('a, 'b) t
    end

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

      include S3_any with type ('a, 'b, 'c) t := ('a, 'b, 'c) t
    end
  end
end

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