Last active
March 24, 2020 13:11
-
-
Save yonta/08abe597c8a8ed1620de0ef88ec68816 to your computer and use it in GitHub Desktop.
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
signature SHOW = | |
sig | |
type t | |
val show : t -> string | |
end | |
structure ShowInt : SHOW where type t = int = | |
struct | |
type t = int | |
val show = Int.toString | |
end | |
structure ShowReal : SHOW where type t = real = | |
struct | |
type t = real | |
val show = Real.toString | |
end | |
(* with a functor *) | |
functor F (M : SHOW) = struct | |
val f = M.show | |
end | |
local | |
structure F_int = F (ShowInt) | |
structure F_real = F (ShowReal) | |
in | |
val x = (F_int.f 42, F_real.f 3.14) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment