Last active
December 16, 2015 11:19
-
-
Save eldesh/5426405 to your computer and use it in GitHub Desktop.
demonstrate datatype replication declarations of SML'97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** | |
* 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://d.hatena.ne.jp/eldesh/20130420/1366474660