File: deriving_num.ml

package info (click to toggle)
ocaml-deriving-ocsigen 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 628 kB
  • ctags: 1,159
  • sloc: ml: 6,334; makefile: 63; sh: 18
file content (30 lines) | stat: -rw-r--r-- 908 bytes parent folder | download | duplicates (3)
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

module Show_num = Deriving_Show.Defaults (struct
  type a = Num.num
  let format formatter item = Format.pp_print_string formatter (Num.string_of_num item)
end)

module Typeable_num    = Deriving_Typeable.Primitive_typeable(struct type t = Num.num let magic = "Primitive.Num.num" end)

module Eq_num : Deriving_Eq.Eq with type a = Num.num =
struct
  type a = Num.num
  let eq = Num.eq_num
end

module Dump_num = Deriving_Dump.Defaults (
  struct
    (* TODO: a less wasteful dumper for nums.  A good start would be
       using half a byte per decimal-coded digit, instead of a whole
       byte. *)
    type a = Num.num
    let to_buffer buffer n = Deriving_Dump.Dump_string.to_buffer buffer (Num.string_of_num n)
    and from_stream stream = Num.num_of_string (Deriving_Dump.Dump_string.from_stream stream)
  end
)



module Pickle_num = Deriving_Pickle.Pickle_from_dump(Dump_num)(Eq_num)(Typeable_num)