File: 125_functor.sml

package info (click to toggle)
smlsharp 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 123,732 kB
  • sloc: ansic: 16,725; sh: 4,347; makefile: 2,191; java: 742; haskell: 493; ruby: 305; cpp: 284; pascal: 256; ml: 255; lisp: 141; asm: 97; sql: 74
file content (47 lines) | stat: -rw-r--r-- 976 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
_interface "125_functor.smi"
(*
  functor F (
 A : sig
   type t
  end
  ) =
  struct
    datatype s = X of A.t
    val f : s -> A.t
  end
*)
functor F (
 A : sig
   type t
 end
) =
struct
  datatype s = X of A.t
  fun f (X x) = x
end

(*
2011-09-06 katsu

This causes an unexpected type error.

125_functor.sml:3.9-11.3 Error:
  (type inference 063-2) type and type annotation don't agree
    inferred type: ({1: 'E('RIGID(tv32))} -> {1: 'E('RIGID(tv32))})
                   -> {1: {FREEBTV(31)}s(t33[]) -> 'E('RIGID(tv32))}
  type annotation: ({1: 'E('RIGID(tv32))} -> {1: 'E('RIGID(tv32))})
                   -> {1: {FREEBTV(32)}s(t35[]) -> 'E('RIGID(tv32))}
*)

(*
2011-09-06 ohori

Fixed.
Functor body environment equivalence check (on spec vs real) 
in CheckProvide must be done under the equivalence relations
(1) on the corresponding newly introduce typIds,
(2) IDCON{id=id1, ty=ty1} = IDCON{id=id1, ty=ty1} iff
    ty1 equiv ty2
(3) IDEXVR _ = IDVAR _ (always)

*)