Skip to content

Instantly share code, notes, and snippets.

@igstan
Last active October 1, 2016 19:35
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 igstan/c566eecc38784216f1499bfe8d91f4c4 to your computer and use it in GitHub Desktop.
Save igstan/c566eecc38784216f1499bfe8d91f4c4 to your computer and use it in GitHub Desktop.
functor Member(Flag : sig type t end) =
struct
(* Define types and values common to both MemberA and MemberB. *)
end
(*
* MemberA and MemberB differ only in the declaration of Flag, the rest of
* the types and values are the same and come from the Member functor.
*)
structure MemberA =
struct
structure Flag =
struct
datatype t = FlagA1 | FlagA2
end
(* Mix in the types and values defined by Member. *)
structure M = Member(Flag) open M
end
structure MemberB =
struct
structure Flag =
struct
datatype t = FlagB1 | FlagB2
end
(* Mix in the types and values defined by Member. *)
structure M = Member(Flag) open M
end
val a = MemberA.Flag.FlagA1
val b = MemberB.Flag.FlagB1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment