You can try to compile and run the hello_world example of ocaml_plugin: https://github.com/janestreet/ocaml_plugin/blob/master/hello_world

It has a Plugin_intf module to specify the type of module expected from loaded file. For you, it should probably be:

module type S = sig
  val equal : ('a * 'a) -> bool
end

Then you can use Ocaml_compiler module to dynamically load modules with this signature as demonstrated in run.ml


On Mon, Feb 24, 2014 at 4:24 AM, Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote:
On 23/02/14 13:12, Tianyi Cui wrote:
> If you know the type of this string in advance, you can do so with ocaml_plugin: https://github.com/janestreet/ocaml_plugin

Hm, imagine that the expected type is:

        'a * 'a -> bool

Now, if user provides a string, say:

        "fun (a,b) -> a = b"

how can I convert that string to Ocaml value of the above type (like how toplevel does it)?

Is this something ocaml_plugin is able to do for me? I've failed to figure out the trick.

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs