* Polymorphic functors / modules and OCaml-R
@ 2009-11-16 7:34 Guillaume Yziquel
2009-11-16 8:11 ` [Caml-list] " Goswin von Brederlow
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Yziquel @ 2009-11-16 7:34 UTC (permalink / raw)
To: caml-list
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Polymorphic functors / modules and OCaml-R
2009-11-16 7:34 Polymorphic functors / modules and OCaml-R Guillaume Yziquel
@ 2009-11-16 8:11 ` Goswin von Brederlow
0 siblings, 0 replies; 2+ messages in thread
From: Goswin von Brederlow @ 2009-11-16 8:11 UTC (permalink / raw)
To: guillaume.yziquel; +Cc: caml-list
Guillaume Yziquel <guillaume.yziquel@citycable.ch> writes:
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-16 8:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-16 7:34 Polymorphic functors / modules and OCaml-R Guillaume Yziquel
2009-11-16 8:11 ` [Caml-list] " Goswin von Brederlow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox