From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: caml-list@inria.fr
Subject: Polymorphic functors / modules and OCaml-R
Date: Mon, 16 Nov 2009 08:34:11 +0100 [thread overview]
Message-ID: <4B010073.6090402@citycable.ch> (raw)
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/
next reply other threads:[~2009-11-16 7:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 7:34 Guillaume Yziquel [this message]
2009-11-16 8:11 ` [Caml-list] " Goswin von Brederlow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B010073.6090402@citycable.ch \
--to=guillaume.yziquel@citycable.ch \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).