File: abstype.sml

package info (click to toggle)
mlton 20130715-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 60,900 kB
  • ctags: 69,386
  • sloc: xml: 34,418; ansic: 17,399; lisp: 2,879; makefile: 1,605; sh: 1,254; pascal: 256; python: 143; asm: 97
file content (77 lines) | stat: -rw-r--r-- 920 bytes parent folder | download | duplicates (10)
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
abstype t = T
with
   val eq = op =
end
val _ = eq (3, 3)

abstype t = T
with
   val t = T
   val eq = op =
end
val _ = eq (t, t)

abstype t = T
with
   val t = T
   val eq = op =
   val _ = eq (t, t)
end
val _ = eq (2, 3)

abstype t = T
with
   val t = T
   val eq = op =
   val _ = eq (t, t)
end
val _ = eq (t, t)

abstype t = T
with
   val t = T
   val eq = op =
   val _ = eq (t, t) andalso eq (2, 3)
end
val _ = eq (2, 3)

(* with abstype *)

structure S =
  struct
    abstype s = S
    with
      val a = S
    end
  end

signature F = 
  sig 
    val b : S.s
  end

functor F() : F =
  struct
    type s = S.s
    val b = S.a
  end


functor K() =
  struct
    structure F = F()
  end

structure K = K()

(* abstype.sml *)

(* Checks equality inferred for abstype environments. *)

abstype t = T with
    datatype u = U of t
    val eq = op=
end

fun eq1(t1, t2) = U t1 = U t2;
fun eq2(t1, t2 : t) = eq(t1, t2);