Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /tests/trunk/bugs/tests.obsolete/bug673.sml
ViewVC logotype

View of /tests/trunk/bugs/tests.obsolete/bug673.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2460 - (download) (annotate)
Sat Apr 28 20:18:10 2007 UTC (12 years, 2 months ago) by gkuan
File size: 733 byte(s)
(* bug673.sml *)
(* example of higher-order functors from Mads Tofte *)

signature MONOID = 
  type t
  val plus: t*t -> t
  val e: t

(* functor signature declaration *)
funsig PROD (structure M: MONOID
	     structure N: MONOID) = MONOID

functor Square(structure X: MONOID
	       functor Prod: PROD): MONOID =
    Prod(structure M = X
         structure N = X);

functor Prod(structure M: MONOID
	     structure N: MONOID): MONOID =
  type t = M.t * N.t
  val e = (M.e, N.e)
  fun plus((m1,n1),(m2,n2))=(M.plus(m1,m2),N.plus(n1,n2))

structure Int =
  type t = int
  val e = 0
  val plus = (op +): int*int -> int

structure Int2 = Square(
  structure X = Int
  functor Prod = Prod);


ViewVC Help
Powered by ViewVC 1.0.0