adamc@674: datatype pair a b = Pair of a * b adamc@211: adamc@674: structure M : sig adamc@674: class default adamc@674: val get : t ::: Type -> default t -> t adamc@211: adamc@674: val string_default : default string adamc@674: val int_default : default int adamc@212: adamc@674: val option_default : t ::: Type -> default t -> default (option t) adamc@674: val pair_default : a ::: Type -> b ::: Type -> default a -> default b -> default (pair a b) adamc@675: adamc@677: (*val uh_oh : t ::: Type -> default t -> default t*) adamc@677: adamc@675: class awesome adamc@675: val awesome_default : t ::: Type -> awesome t -> default t adamc@675: adamc@675: val float_awesome : awesome float adamc@677: adamc@677: val oh_my : t ::: Type -> awesome (option t) -> awesome (option t) adamc@677: adamc@677: val awesome : t ::: Type -> awesome t -> t adamc@674: end = struct adamc@674: class default t = t adamc@674: fun get (t ::: Type) (x : t) = x adamc@212: adamc@674: val string_default = "Hi" adamc@674: val int_default = 0 adamc@674: adamc@674: fun option_default (t ::: Type) (x : t) = Some x adamc@674: fun pair_default (a ::: Type) (b ::: Type) (x : a) (y : b) = Pair (x, y) adamc@675: adamc@677: (*fun uh_oh (t ::: Type) (x : t) = x*) adamc@677: adamc@675: class awesome t = t adamc@675: fun awesome_default (t ::: Type) (x : t) = x adamc@675: adamc@675: val float_awesome = 1.23 adamc@677: adamc@677: fun oh_my (t ::: Type) (x : option t) = x adamc@677: adamc@677: fun awesome (t ::: Type) (x : t) = x adamc@674: end adamc@674: adamc@674: open M adamc@674: adamc@674: fun default (t ::: Type) (_ : default t) : t = get adamc@674: val hi : string = default adamc@674: val zero : int = default adamc@674: val some_zero : option int = default adamc@674: val hi_zero : pair string int = default adamc@675: val ott : float = default adamc@674: adamc@674: fun frob (t ::: Type) (_ : default t) : t = default adamc@674: val hi_again : string = frob adamc@674: val zero_again : int = frob adamc@674: adamc@674: fun show_option (t ::: Type) (_ : show t) : show (option t) = adamc@674: mkShow (fn x => adamc@674: case x of adamc@674: None => "None" adamc@674: | Some y => show y) adamc@674: adamc@677: (*val x : option float = awesome*) adamc@677: adamc@674: fun show_pair (a ::: Type) (b ::: Type) (_ : show a) (_ : show b) : show (pair a b) = adamc@674: mkShow (fn x => adamc@674: case x of adamc@674: Pair (y, z) => "(" ^ show y ^ "," ^ show z ^ ")") adamc@674: adamc@674: fun main () : transaction page = return adamc@675: {[hi_again]}, {[zero_again]}, {[some_zero]}, {[hi_zero]}, {[ott]} adamc@674: