List Info

Thread: "ocaml_beginners"::[] Re: problem with recursive modules?




"ocaml_beginners"::[] Re: problem with recursive modules?
user name
2006-12-08 17:13:00

Le ven 08 déc 2006 17:03:14 CET,
&quot;drehman27" < drehman27%40yahoo.com">drehman27yahoo.com> a écrit :

> It still doesn't work. Could you please fix my example so that it
> compiles? Thanks

Sure, here it is:

module type Algorithm =
sig
val run_algorithm : unit -> unit
end

module type FrameworkType =
sig
val print_benchmark_results : unit -> unit
end

module Framework =
functor (Alg : Algorithm) ->
(struct
let print_benchmark_results () = print_endline "Excelent!"
end: FrameworkType)

module rec FooAlgorithm : Algorithm =
struct
let run_algorithm () = ()
let results () = BenchmarkFoo.print_benchmark_results ()
end
and BenchmarkFoo : FrameworkType = Framework(FooAlgorithm)

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

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] Re: problem with recursive modules?
user name
2006-12-08 18:31:23

The difference is here:

My version (that doesn't compile):
module Framework : FrameworkType =
functor (Alg : Algorithm) ->
struct
let print_benchmark_results () = print_endline "Excelent!"
end

Your version (correct):
module Framework =
functor (Alg : Algorithm) ->
(struct
let print_benchmark_results () = print_endline "Excelent!"
end: FrameworkType)

I thought that you could define a functor either way. I don't
understand what's wrong with my definition!
Anyway, thanks a lot for the example.

module Name : Type =
functor (..) ->
struct
...
end

or

module Name =
functor (..) ->
(struct
...
end: Type)

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )