caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Module/Functor modelisation
@ 2002-08-14  7:07 Johan Baltié
       [not found] ` <20020814074250.GA6002@barcelona.lrde.epita.fr>
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Baltié @ 2002-08-14  7:07 UTC (permalink / raw)
  To: caml-list

Hi !

I have a simple functor:

module type Used =
sig 
 type output

 val toto : int -> output -> output
 val tutu : double -> output -> output
end

module type User =
 functor (U : Used) ->
sig

 val toto : int -> U.output -> U.output
 val tutu : double -> U.output -> U.output
end

And User is implemented by two types doing mostly the same things with different
init, and with recursive and/or mutual call in toto an tutu.

I'd like to factorize the shared code, BUT the recursive call prevent me of
doing this. Here an implementation example of the part where the problem lie:

 module User1: User =
   functor (U : Used) ->
 struct
   let toto i output = 
     let val = U.tutu 12.0 output
     in
      tutu 12.0 val

    let rec tutu d output =
       if (d = 11.0) then
          output
       else
          tutu (d -. 1.0) (U.toto 1 output)
 end



 module User2: User =
   functor (U : Used) ->
 struct
   let toto i output = 
     let val = tutu 12.0 output
     in
      U.tutu 12.0 val

    let rec tutu d output =
       if (d = 11.0) then
          output
       else
          let val = tutu (d -. 1.0) output
           in
               U.toto 1 val
 end


Basicly I once do things in a Prefix way, and once in a postfix way.
I would like to call in User toto and tutu function like:

 let toto i data =
   Used.tutu 12.0 data

  let tutu d output =
     User.tutu (d -. 1.0) output

My problem lays here. I cannot now which User.tutu to call. If I try to make a
functor that do take a User module, there is a recursion problem as this functor
will need a User module and the user module will need this functor to be able to
call the helping functions ! It's gaving me headache....

I know this explanation is not really clear, but I tried to simplify my problem
in order to explain it and I fear people won't see any usefullness in my needs. 

Thanks in advance

Ciao

Jo
-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Caml-list] Module/Functor modelisation
@ 2002-08-14  6:55 Johan Baltié
  2002-08-14  7:10 ` Johan Baltié
  0 siblings, 1 reply; 6+ messages in thread
From: Johan Baltié @ 2002-08-14  6:55 UTC (permalink / raw)
  To: caml-list

Hi !

I have a simple functor:

module type Used =
sig 
 type output

 val toto : int -> output -> output
 val tutu : double -> output -> output
end

module type User =
 functor (U : Used) ->
sig

 val toto : int -> U.output -> U.output
 val tutu : double -> U.output -> U.output
end

And User is implemented by two types doing mostly the same things with different
init, and with recursive and/or mutual call in toto an tutu.

I'd like to factorize the shared code, BUT the recursive call prevent me of
doing this. Here an implementation example of the part where the problem lie:

 module User1: User =
   functor (U : Used) ->
 struct
   let toto i output = 

 end

Ciao

Jo
-------------------
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-08-14  9:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-14  7:07 [Caml-list] Module/Functor modelisation Johan Baltié
     [not found] ` <20020814074250.GA6002@barcelona.lrde.epita.fr>
     [not found]   ` <20020814074844.M48926@epita.fr>
2002-08-14  7:49     ` Fw: " Johan Baltié
     [not found]       ` <20020814083553.GC6002@barcelona.lrde.epita.fr>
     [not found]         ` <20020814083157.M89732@wanadoo.fr>
     [not found]           ` <20020814090548.GD6002@barcelona.lrde.epita.fr>
     [not found]             ` <20020814085806.M98813@wanadoo.fr>
2002-08-14  9:33               ` Yann Régis-Gianas
     [not found]                 ` <20020814093239.M61475@wanadoo.fr>
2002-08-14 10:00                   ` Yann Régis-Gianas
  -- strict thread matches above, loose matches on Subject: below --
2002-08-14  6:55 Johan Baltié
2002-08-14  7:10 ` Johan Baltié

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).