deriving (Enum) now uses Deriving_Enum module [#1]
[deriving.git] / lib / bounded.ml
blob69220a238a67e4dc9b77c7b186982f2596a2b29a
1 (*pp deriving *)
2 (* Copyright Jeremy Yallop 2007.
3 This file is free software, distributed under the MIT license.
4 See the file COPYING for details.
5 *)
7 (** Primitive instanecs for bounded **)
8 module Bounded = struct
9 module type Bounded = sig
10 type a
11 val min_bound : a
12 val max_bound : a
13 end
15 module Bounded_integer(B : sig type t
16 val max_int : t
17 val min_int : t
18 end) : Bounded with type a = B.t =
19 struct
20 type a = B.t
21 let min_bound = B.min_int
22 let max_bound = B.max_int
23 end
24 module Bounded_int32 = Bounded_integer(Int32)
25 module Bounded_int64 = Bounded_integer(Int64)
26 module Bounded_nativeint = Bounded_integer(Nativeint)
27 module Bounded_int = struct
28 type a = int
29 let min_bound = Pervasives.min_int
30 let max_bound = Pervasives.max_int
31 end
32 module Bounded_bool = struct
33 type a = bool
34 let min_bound = false
35 let max_bound = true
36 end
37 module Bounded_char = struct
38 type a = char
39 let min_bound = Char.chr 0
40 let max_bound = Char.chr 0xff (* Is this guaranteed? *)
41 end
42 module Bounded_unit = struct
43 type a = unit
44 let min_bound = ()
45 let max_bound = ()
46 end
47 end
48 include Bounded
49 type open_flag = Pervasives.open_flag =
50 | Open_rdonly
51 | Open_wronly
52 | Open_append
53 | Open_creat
54 | Open_trunc
55 | Open_excl
56 | Open_binary
57 | Open_text
58 | Open_nonblock
59 deriving (Bounded)
61 type fpclass = Pervasives.fpclass =
62 | FP_normal
63 | FP_subnormal
64 | FP_zero
65 | FP_infinite
66 | FP_nan
67 deriving (Bounded)