Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created September 28, 2014 14:38
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 pasberth/c9f95d8a179070060aab to your computer and use it in GitHub Desktop.
Save pasberth/c9f95d8a179070060aab to your computer and use it in GitHub Desktop.
SML# のオーバーロード
_require "basis.smi"
structure B =
struct
val g : int -> int
val h : string -> string
end
val f = case 'a in 'a -> 'a of
int => B.g
| string => B.h
structure B =
struct
val g = fn x => x + 1
val h = fn x => x
end
_require "basis.smi"
_require "./b.smi"
val () = print (f "a") (* a *)
val () = print (Int.toString (f 1)) (* 2 *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment