File: test.ml

package info (click to toggle)
otags 3.09.3-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 372 kB
  • ctags: 296
  • sloc: ml: 1,004; sh: 309; makefile: 122
file content (96 lines) | stat: -rw-r--r-- 1,447 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
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
93
94
95
96
(* (C) 1999-2004                                                 *)
(* Cuihtlauac Alvarado, France Telecon, Recherche & Developement *)
(* Jean-Franois Monin, Universit Joseph Fourier - VERIMAG      *)

(* $Id: test.ml,v 1.9 2004-09-03 08:51:10 tews Exp $ *)

let f1 x = 12
(*
type a =
  | A of int  | B
*)
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

(* Bug pointed by Hendrik Tews *)
(* Status: not fixed *)

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;;