Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Structure subtyping *)
- signature SIG1 = sig
- type t
- val x : t
- end
- signature SIG2 = sig
- val x : int
- end
- signature SIG1AND2 = sig
- type t = int
- val x : t
- end
- functor F(X : SIG1AND2) = struct
- structure A : SIG1 = X
- structure B : SIG2 = X
- end
- (* functor F : SIG1AND2 -> (sig structure A : SIG1 and B : SIG2 end) *)
- fun f X =
- let structure A as SIG1 = X
- structure B as SIG2 = X (* Type error here *)
- in ()
- end
- (* Type mismatch, X must have both types: [ SIG1 ] and [ SIG2 ] *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement