From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9B5367F84F for ; Mon, 24 Feb 2014 06:06:02 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of tcui@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tcui@janestreet.com"; x-sender="tcui@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of tcui@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tcui@janestreet.com"; x-sender="tcui@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@tot-dmz-mxout1.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="tcui@janestreet.com"; x-sender="postmaster@tot-dmz-mxout1.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtsBAMvSClMmacjlnGdsb2JhbABZg0FXqkGNTIhWgQceDgEBAQEBBhYJPIIlAQEEAScZAQEsCwEECwsEBw0NISEBEgEFAQoSBhMSh18DCQgDAgiZO4sVhFcBBZVGAwqHMhEGjE+CEQQHhDiJSo0BgW2BMosug1oYKYRm X-IPAS-Result: AtsBAMvSClMmacjlnGdsb2JhbABZg0FXqkGNTIhWgQceDgEBAQEBBhYJPIIlAQEEAScZAQEsCwEECwsEBw0NISEBEgEFAQoSBhMSh18DCQgDAgiZO4sVhFcBBZVGAwqHMhEGjE+CEQQHhDiJSo0BgW2BMosug1oYKYRm X-IronPort-AV: E=Sophos;i="4.97,532,1389740400"; d="scan'208";a="50200794" Received: from mx5.janestreet.com (HELO tot-dmz-mxout1.janestreet.com) ([38.105.200.229]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Feb 2014 06:06:01 +0100 Received: from tot-oib-smtp1.delacy.com ([172.27.22.15] helo=tot-smtp) by tot-dmz-mxout1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1WHnjq-0002YJ-2K for caml-list@inria.fr; Mon, 24 Feb 2014 00:05:58 -0500 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WHnjq-0000FI-0z for caml-list@inria.fr; Mon, 24 Feb 2014 00:05:58 -0500 Received: from mail-we0-f174.google.com ([74.125.82.174]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1WHnjp-0001ce-TO for caml-list@inria.fr; Mon, 24 Feb 2014 00:05:57 -0500 Received: by mail-we0-f174.google.com with SMTP id w61so4191372wes.5 for ; Sun, 23 Feb 2014 21:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=vq+V5FJsFf8bpA6r9Bfiku397NdVPqFKYvc0PR8Ux2A=; b=yLrN85NAxl5VLxpDeZmjEeZJGfhfL92uck8Sty4kGVKXFki7+4GiDMQw+h9nU9GDpS b4BijkwGfzIDQz8Z/RyHbLUp1nRNsJC3aM8ARdQRCGvvu4Iut0LH/1lgoQZfHeVRo0ql 26GrTTLtBa1IMOIms3wySsVayVUg2hfFlQI+A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=vq+V5FJsFf8bpA6r9Bfiku397NdVPqFKYvc0PR8Ux2A=; b=FaL8bs/21yBB+vN+2w7lS5IF3TaNUlgTWOXUmMagoZXq9C7ojl0PBcKQDcJp4NftrN 8m0CH1XcCBEYuDlj2SdaFf99kEosxXGicpVlyf2eL8Gmh4eWoPHwhA+KYfCpNqdCl3Bm eAvjZumJUhe3n/5EENumW0ILRbd08kkpSadPHyyfKIlI232dwiRY4whPs+6hjGJR3n4m pnFeeSltFF+baFqYnrX7+c3+Z+XVuFz9WWDgdH7hvfTCRoCuxPtxRVDhXTkoJ9SD7t9b GNpICYadSVN6RIkmldNKrBL3bTDZ29iS0AX4nV9f5+IX6rxIpgXf3ZhxUQYgL7i323MP MHOA== X-Gm-Message-State: ALoCoQmGlWd4hSM79mnlmAO1KR4Bk0ptWS02iDlXwBxFaXEL+Twx3W8Hkqg0juNxbka0sk/3OMbEsxhFhagl/5ZBj25xOEFbbyRxZRoEWrqEP47OhTUj+HSHndf70Z1mKXkQIEiaffFCxV3dRaqZXtz33wNTspFNhA== X-Received: by 10.194.174.234 with SMTP id bv10mr16889285wjc.66.1393218357426; Sun, 23 Feb 2014 21:05:57 -0800 (PST) X-Received: by 10.194.174.234 with SMTP id bv10mr16889277wjc.66.1393218357327; Sun, 23 Feb 2014 21:05:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.110.134 with HTTP; Sun, 23 Feb 2014 21:05:17 -0800 (PST) In-Reply-To: <530A590B.2040004@gmail.com> References: <5309E82E.5060802@gmail.com> <530A590B.2040004@gmail.com> From: Tianyi Cui Date: Mon, 24 Feb 2014 13:05:17 +0800 Message-ID: To: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=089e013d185c487bf504f31fed19 X-Sender-Copy: hkg-copy Subject: Re: [Caml-list] how to convert strings to Ocaml values at run-time? --089e013d185c487bf504f31fed19 Content-Type: text/plain; charset=ISO-8859-1 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 > --089e013d185c487bf504f31fed19 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
You can try to compile and run the hello_world example of = ocaml_plugin: https://github.com/janestreet/ocaml_plugin/blob/master/he= llo_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 =3D sig<= br>=A0 val equal : ('a * 'a) -> bool
end

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


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

Hm, imagine that the expected type is:

=A0 =A0 =A0 =A0 'a * 'a -> bool

Now, if user provides a string, say:

=A0 =A0 =A0 =A0 "fun (a,b) -> a =3D b"

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

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

--
Caml-list mailing list. =A0Subscription management and archives:
ht= tps://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

--089e013d185c487bf504f31fed19--