I've been trying stuff like these:
> # module type 'a A = sig
> Error: Parse error: [a_UIDENT] expected after "type" (in [str_item])
> # module type ['a] A = sig
> Error: Parse error: [a_UIDENT] expected after "type" (in [str_item])
> # module type A = sig module type B end
> ;;
> Error: Failure: "abstract/nil module type not allowed here"
> #
Is there a way, somehow, of introducing such polymorphism in modules /
functors?
That would help me a lot. I'm currently try to write bindings for R
code, with OCaml-R, and I can come up with stuff like this:
> module Description : R.LibraryDescription = struct
> let name = "xts"
> let symbols = ["xts"]
> end
>
> module Library : R.Library = OCamlR.Require (Description)
>
> let [xts] = Library.root
What would be nice would be Description to be polymorphic in some sense
or another, so that I could describe the various R symbols that are made
available by the xts library.
The other, rather unrelated solution I see would be to replace stuff
above by something like:
> module Description : R.LibraryDescription = struct
> let name = "xts"
> let symbols = ["xts"; "print_xts"]
> end
> module Library : R.Library = OCamlR.Require (Description)
>
> type t
> external list_to_tuple : 'a list -> 'b = "list_to_tuple"
> let ( (xts : unit -> t),
> (print_xts : t -> unit)
> ) = list_to_tuple Library.root
where list_to_tuple would be a function constructing the tuple (no fixed
size) representing a given list. This is rather unsafe...
A polymorphic module, with argument a module type, would be something
very useful to describe a R library...
All the best,
--
Guillaume Yziquel
http://yziquel.homelinux.org/
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
> Hello.
>
> I've been trying stuff like these:
>
>> # module type 'a A = sig
>> Error: Parse error: [a_UIDENT] expected after "type" (in [str_item])
>> # module type ['a] A = sig
>> Error: Parse error: [a_UIDENT] expected after "type" (in [str_item])
>> # module type A = sig module type B end
>> ;;
>> Error: Failure: "abstract/nil module type not allowed here"
>> #
>
> Is there a way, somehow, of introducing such polymorphism in modules /
> functors?
Isn't that exactly what a functor is? You just need to wrape the 'a type
in a module.
MfG
Goswin