annotate tests/functor.lac @ 44:a9f3ce2d1b9b

Elaborating functor applications
author Adam Chlipala <adamc@hcoop.net>
date Thu, 19 Jun 2008 17:04:08 -0400
parents d94c484337d0
children 44a1bc863f0f
rev   line source
adamc@40 1 signature S = sig
adamc@40 2 type t
adamc@40 3 val z : t
adamc@40 4 val s : t -> t
adamc@40 5 end
adamc@40 6
adamc@40 7 signature T = sig
adamc@40 8 type t
adamc@40 9 val three : t
adamc@40 10 end
adamc@40 11
adamc@42 12 functor F (M : S) : T where type t = M.t = struct
adamc@41 13 type t = M.t
adamc@40 14 val three = M.s (M.s (M.s M.z))
adamc@40 15 end
adamc@43 16
adamc@43 17 structure F2 : functor (M : S) : T where type t = M.t = F
adamc@43 18 structure F3 : functor (M : S) : T = F
adamc@43 19 (*structure F4 : functor (M : S) : sig type q end = F*)
adamc@43 20 (*structure F5 : functor (M : S) : T where type t = int = F*)
adamc@44 21
adamc@44 22
adamc@44 23 structure O = F (struct
adamc@44 24 type t = int
adamc@44 25 val z = 0
adamc@44 26 val s = fn x : t => x
adamc@44 27 end)
adamc@44 28 val three : int = O.three
adamc@44 29
adamc@44 30 structure S = struct
adamc@44 31 type t = int
adamc@44 32 val z = 0
adamc@44 33 val s = fn x : t => x
adamc@44 34 end
adamc@44 35 structure SO = F (S)
adamc@44 36 val three : int = SO.three
adamc@44 37
adamc@44 38 structure SS : S = S
adamc@44 39 structure SSO = F (SS)
adamc@44 40 val three : SS.t = SSO.three