File: d.ml

package info (click to toggle)
otags 4.05.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 504 kB
  • sloc: ml: 1,293; sh: 212; makefile: 195
file content (92 lines) | stat: -rw-r--r-- 1,205 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

let f1 x = 12

type a =
  | A of int
  | B  | C

type b = {g:int;           rr:int}

let f2 = function
  | A x -> x
  | y -> 10

;;
let f1 = 12 in f1
;;

module type END = sig 
  type end_t 
  val end_val : end_t
end

let rec f2 = function
  | A x -> x
  | y -> 10

let f3, f4 = 0, 1

let f5 as f6 = fun x -> x

let f7 : int -> int = fun x -> x

module Modu =
  struct let mof = 3 end

exception No_value

let value = function
  | None -> raise No_value
  | Some x -> x

class int_value init = object (self)

  val mutable r = init;

  method get = value r;

  method set n = r <- Some n;

  method add n = match r with
    | None -> self#set n
    | Some m -> r <- Some (n + m);

end

let f8 : int -> int = fun x -> x

type a_type = 
  | A1 of b_type
  | A2 of a_type

and b_type = 
  | B1 of b_type
  | B2 of a_type


class ['a] c (a : 'a ) = object 
  method b = a 
end

and ['a] d (a : 'a ) = object 
  method dm = a 
end

class b_class = [int * int] c

class x = 
  (fun o ->  object method x = o end) 5

class type x_class = object
  val mutable y : int
end
;;

let ( <:> ) x y = x + y;;

let Modu.(d20) = 20


(*** Local Variables: ***)
(*** compile-command: "make -C .. test" ***)
(*** End: ***)