Skip to content

Instantly share code, notes, and snippets.

@eldesh
Last active December 16, 2015 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eldesh/5426405 to your computer and use it in GitHub Desktop.
Save eldesh/5426405 to your computer and use it in GitHub Desktop.
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
Copy link
Author

eldesh commented Apr 21, 2013

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