[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Nicolas FRANCOIS <nicolas.francois@f...> |
| Subject: | Re: [Caml-list] About modules again |
Le Mon, 15 Jul 2002 10:44:35 +0200 Markus Mottl <markus@oefai.at> a écrit
:
> This is the point where higher-order modules (functors) enter the game.
> If you have some common functionality that is shared across all rings,
> you can factor it out in a functor body. E.g.:
>
> module MakeRing (Spec : RING_SPEC) : RING = struct
> include Spec
>
> (* All common stuff follows here *)
> end
>
> Module "Spec" should adhere to a signature "RING_SPEC", the latter
> specifying what is different or at least parameterizable for each
> ring. Applying the functor to such a specification yields a module that
> implements the signature RING, e.g.:
>
> module Ring_Z = MakeRing (Ring_Z_Spec)
>
> The specification of rings over Z (Ring_Z_Spec) may itself be the result
> of a functor application. This way you can highly modularize the
> creation of algebraic structures.
I see your point. Conway does something like this in his math packages.
I'll try to adapt the technique.
Thanks Markus.
\bye
--
Nicolas FRANCOIS
http://nicolas.francois.free.fr
A TRUE Klingon programmer does NOT comment his code
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners