Version française
Home     About     Download     Resources     Contact us    
Browse thread
any types in signatures of functor arguments
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Virgile Prevosto <virgile.prevosto@m...>
Subject: Re: [Caml-list] any types in signatures of functor arguments
Le mar 25 oct 2005 11:22:20 CEST, Keiko Nakata <keiko@kurims.kyoto-
u.ac.jp> a ecrit:

> So it seems that I cannot avoid modifying modules to which F is
> applied. Actually, I already written several modules, say M and N, in
> separate files. Later, I defined the functor F so as to apply it to
> the modules M and N. I thought that it would be nice if I can avoid
> modifying the implementations and interface files of M and N,
> since it will affect other parts of my program.
> 

It might be possible to only modify the arguments you give to F, with
the use of include:

module M = struct let f (`A x) = x end

module F(X:sig type s type t = [ `A of s] val f: t -> int end) =
  struct let f = function `A _ as a -> X.f a | `B -> 0
  end;;

module FM = F(struct include M type s = int type t = [ `A of s ])

-- 
E tutto per oggi, a la prossima volta
Virgile