File: deriving_Default.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 (65 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download | duplicates (2)
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
module type Default = sig
  type a
  val default : unit -> a
end

module Defaults(D : Default) : Default with type a = D.a = struct
  include D
end

module Default_string = Defaults(struct
  type a = string
  let default () = ""
end)

module Default_int64 = Defaults(struct
  type a = int64
  let default () = 0L
end)


module Default_int = Defaults(struct
  type a = int
  let default () = 0
end)

module Default_bool = Defaults(struct
  type a = bool
  let default () = true
end)

module Default_unit = Defaults(struct
  type a = unit
  let default () = ()
end)

module Default_char = Defaults(struct
  type a = char
  let default () = '0'
end)

module Default_float = Defaults(struct
  type a = float
  let default () = 0.0
end)

module Default_list (A : Default) = Defaults(struct
  type a = A.a list
  let default () = []
end)

module Default_option (A : Default) = Defaults(struct
  type a = A.a option
  let default () = None
end)

module Default_array (A : Default) = Defaults(struct
  type a = A.a array
  let default () = [||]
end)


module Default_ref (A : Default) = Defaults(struct
  type a = A.a ref
  let default () = ref (A.default ())
end)