Skip to content

Instantly share code, notes, and snippets.

@eldesh

eldesh/demo.sml

Last active Dec 16, 2015
Embed
What would you like to do?
demonstrate datatype replication declarations of SML'97
(**
* datatype replication declarations(specifications)のサンプル
*)
(** monomorphic version *)
structure S =
struct
datatype either = L | R
end
structure F1 =
struct
type either = S.either
val vL = S.L
end
structure F2 =
struct
datatype either = datatype S.either (* datatype replication declarations *)
val vL = S.L
end
(** polymorphic version *)
structure S =
struct
datatype ('a,'b) poly_either = Left of 'a | Right of 'b
end
structure F1 =
struct
type ('a,'b) poly_either = ('a,'b) S.poly_either
val pvL = S.Left 5
end
structure F2 =
struct
datatype poly_either = datatype S.poly_either (* datatype replication declarations *)
val pvL = S.Left 5
end
@eldesh

This comment has been minimized.

Copy link
Owner Author

@eldesh eldesh commented Apr 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment