Version française
Home     About     Download     Resources     Contact us    
Browse thread
Polymorphic functors / modules and OCaml-R
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Guillaume Yziquel <guillaume.yziquel@c...>
Subject: Polymorphic functors / modules and OCaml-R
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?

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/