caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Parsing cmi file
@ 2012-03-13 21:52 bob zhang
  2012-03-13 22:36 ` Gerd Stolpmann
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: bob zhang @ 2012-03-13 21:52 UTC (permalink / raw)
  To: Caml List

Hi list,
   I noticed that Godi can pretty print cmi files, is there already
libraries parsing cmi files?
Many thanks
-- 
-- Bob

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-13 21:52 [Caml-list] Parsing cmi file bob zhang
@ 2012-03-13 22:36 ` Gerd Stolpmann
  2012-03-13 23:20   ` bob zhang
  2012-03-14  6:48 ` rixed
  2012-03-14 18:09 ` [Caml-list] " Richard W.M. Jones
  2 siblings, 1 reply; 14+ messages in thread
From: Gerd Stolpmann @ 2012-03-13 22:36 UTC (permalink / raw)
  To: bob zhang; +Cc: Caml List


> Hi list,
>    I noticed that Godi can pretty print cmi files, is there already
> libraries parsing cmi files?

Yes, toplevellib.cma (i.e. the ocaml toploop). It's a silly trick. Run the
toploop and do

module M = <NameOfTheCMI>;;

and the toploop responds.

Gerd

> Many thanks
> --
> -- Bob
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
>


-- 
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
*** Searching for new projects! Need consulting for system
*** programming in Ocaml? Gerd Stolpmann can help you.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-13 22:36 ` Gerd Stolpmann
@ 2012-03-13 23:20   ` bob zhang
  2012-03-14  0:25     ` Gerd Stolpmann
  0 siblings, 1 reply; 14+ messages in thread
From: bob zhang @ 2012-03-13 23:20 UTC (permalink / raw)
  To: Gerd Stolpmann; +Cc: Caml List

Thanks.
I know the dirty tricks, is there some way not that dirty?
Godi did pretty printing this way?
On Tue, Mar 13, 2012 at 6:36 PM, Gerd Stolpmann <info@gerd-stolpmann.de> wrote:
>
>> Hi list,
>>    I noticed that Godi can pretty print cmi files, is there already
>> libraries parsing cmi files?
>
> Yes, toplevellib.cma (i.e. the ocaml toploop). It's a silly trick. Run the
> toploop and do
>
> module M = <NameOfTheCMI>;;
>
> and the toploop responds.
>
> Gerd
>
>> Many thanks
>> --
>> -- Bob
>>
>> --
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa-roc.inria.fr/wws/info/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>
>>
>>
>
>
> --
> Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
> Creator of GODI and camlcity.org.
> Contact details:        http://www.camlcity.org/contact.html
> Company homepage:       http://www.gerd-stolpmann.de
> *** Searching for new projects! Need consulting for system
> *** programming in Ocaml? Gerd Stolpmann can help you.
>



-- 
-- Bob


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-13 23:20   ` bob zhang
@ 2012-03-14  0:25     ` Gerd Stolpmann
  2012-03-14 17:14       ` David Brown
  0 siblings, 1 reply; 14+ messages in thread
From: Gerd Stolpmann @ 2012-03-14  0:25 UTC (permalink / raw)
  To: bob zhang; +Cc: Caml List


> Thanks.
> I know the dirty tricks, is there some way not that dirty?
> Godi did pretty printing this way?

Yes. But why do you consider it as dirty? There is nothing wrong with it,
isn't it? This uses a helper program with a well-defined interface.

I think you can also "use" ocamlc -i for it, maybe easier to wrap.

Gerd

> On Tue, Mar 13, 2012 at 6:36 PM, Gerd Stolpmann <info@gerd-stolpmann.de>
> wrote:
>>
>>> Hi list,
>>>    I noticed that Godi can pretty print cmi files, is there already
>>> libraries parsing cmi files?
>>
>> Yes, toplevellib.cma (i.e. the ocaml toploop). It's a silly trick. Run
>> the
>> toploop and do
>>
>> module M = <NameOfTheCMI>;;
>>
>> and the toploop responds.
>>
>> Gerd
>>
>>> Many thanks
>>> --
>>> -- Bob
>>>
>>> --
>>> Caml-list mailing list.  Subscription management and archives:
>>> https://sympa-roc.inria.fr/wws/info/caml-list
>>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>>
>>>
>>>
>>
>>
>> --
>> Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
>> Creator of GODI and camlcity.org.
>> Contact details:        http://www.camlcity.org/contact.html
>> Company homepage:       http://www.gerd-stolpmann.de
>> *** Searching for new projects! Need consulting for system
>> *** programming in Ocaml? Gerd Stolpmann can help you.
>>
>
>
>
> --
> -- Bob
>
>


-- 
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
*** Searching for new projects! Need consulting for system
*** programming in Ocaml? Gerd Stolpmann can help you.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-13 21:52 [Caml-list] Parsing cmi file bob zhang
  2012-03-13 22:36 ` Gerd Stolpmann
@ 2012-03-14  6:48 ` rixed
  2012-03-14 17:30   ` [Caml-list] " Hongbo Zhang
  2012-03-14 18:09 ` [Caml-list] " Richard W.M. Jones
  2 siblings, 1 reply; 14+ messages in thread
From: rixed @ 2012-03-14  6:48 UTC (permalink / raw)
  To: Caml List

-[ Tue, Mar 13, 2012 at 05:52:37PM -0400, bob zhang ]----
> Hi list,
>    I noticed that Godi can pretty print cmi files, is there already
> libraries parsing cmi files?

Yes you can do this using the compiler libs (not installed by default
but debian have these in a separate package).
For an exemple of use see for instance the small tool displaying mli
signatures from this git repo:

git clone http://git.gitorious.org/ocalme/cmidump.git



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-14  0:25     ` Gerd Stolpmann
@ 2012-03-14 17:14       ` David Brown
  0 siblings, 0 replies; 14+ messages in thread
From: David Brown @ 2012-03-14 17:14 UTC (permalink / raw)
  To: Gerd Stolpmann; +Cc: bob zhang, Caml List

On Wed, Mar 14, 2012 at 01:25:49AM +0100, Gerd Stolpmann wrote:
>
>> Thanks.
>> I know the dirty tricks, is there some way not that dirty?
>> Godi did pretty printing this way?
>
>Yes. But why do you consider it as dirty? There is nothing wrong with it,
>isn't it? This uses a helper program with a well-defined interface.
>
>I think you can also "use" ocamlc -i for it, maybe easier to wrap.

ocamlc -i will print out all of the types of the .ml file, not just
the interface.  It's useful, but not necessarily what is wanted.

The top trick doesn't work if the code isn't byte-compiled and has the
consequence of running the module.

It would be handy to be able to actually just dump out the .cmi file,
especially in cases, such as prebuilt packages that include the .cmi but
left out the .ml files.

David

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Caml-list] Re: Parsing cmi file
  2012-03-14  6:48 ` rixed
@ 2012-03-14 17:30   ` Hongbo Zhang
  2012-03-14 17:38     ` rixed
  0 siblings, 1 reply; 14+ messages in thread
From: Hongbo Zhang @ 2012-03-14 17:30 UTC (permalink / raw)
  To: rixed; +Cc: Caml List

On 3/14/12 2:48 AM, rixed@happyleptic.org wrote:
> -[ Tue, Mar 13, 2012 at 05:52:37PM -0400, bob zhang ]----
>> Hi list,
>>     I noticed that Godi can pretty print cmi files, is there already
>> libraries parsing cmi files?
It works, if you use godi, compiler-lib is there, thanks.

Another thought, I know there is a tool of hoogle for ocaml, but it's 
online, is there some offline hoogle offline?

I miss the hoogle tool in haskell
>
> Yes you can do this using the compiler libs (not installed by default
> but debian have these in a separate package).
> For an exemple of use see for instance the small tool displaying mli
> signatures from this git repo:
>
> git clone http://git.gitorious.org/ocalme/cmidump.git
>
>
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Caml-list] Re: Parsing cmi file
  2012-03-14 17:30   ` [Caml-list] " Hongbo Zhang
@ 2012-03-14 17:38     ` rixed
  2012-03-14 17:49       ` Raphael Proust
  2012-03-14 17:50       ` Dmitry Grebeniuk
  0 siblings, 2 replies; 14+ messages in thread
From: rixed @ 2012-03-14 17:38 UTC (permalink / raw)
  To: Caml List

-[ Wed, Mar 14, 2012 at 01:30:29PM -0400, Hongbo Zhang ]----
> Another thought, I know there is a tool of hoogle for ocaml, but
> it's online, is there some offline hoogle offline?

Yes, ocamlbrowser (if you have support for Tk).
IIRC you can search by type.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Re: Parsing cmi file
  2012-03-14 17:38     ` rixed
@ 2012-03-14 17:49       ` Raphael Proust
  2012-03-14 17:50       ` Dmitry Grebeniuk
  1 sibling, 0 replies; 14+ messages in thread
From: Raphael Proust @ 2012-03-14 17:49 UTC (permalink / raw)
  To: rixed; +Cc: Caml List

There is the cmigrep tool found on http://homepage.mac.com/letaris/ .
I have no idea about current status though;
http://jun.furuse.info/hacks seems to imply it works on 3.12.

On Wed, Mar 14, 2012 at 6:38 PM,  <rixed@happyleptic.org> wrote:
> -[ Wed, Mar 14, 2012 at 01:30:29PM -0400, Hongbo Zhang ]----
>> Another thought, I know there is a tool of hoogle for ocaml, but
>> it's online, is there some offline hoogle offline?
>
> Yes, ocamlbrowser (if you have support for Tk).
> IIRC you can search by type.
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
_______
Raphael


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Re: Parsing cmi file
  2012-03-14 17:38     ` rixed
  2012-03-14 17:49       ` Raphael Proust
@ 2012-03-14 17:50       ` Dmitry Grebeniuk
  1 sibling, 0 replies; 14+ messages in thread
From: Dmitry Grebeniuk @ 2012-03-14 17:50 UTC (permalink / raw)
  To: rixed

Hello.

> Yes, ocamlbrowser (if you have support for Tk).
> IIRC you can search by type.

  This search doesn't handle equality of type variables.
For example, if you search "  'a -> 'a -> 'a  ", you'll find
"Arg.parse" (among other functions), which has type

val parse :
  (Arg.key * Arg.spec * Arg.doc) list ->
  Arg.anon_fun -> Arg.usage_msg -> unit

  (and more, the last 'a here stands for
"Arg.usage_msg -> unit", which is good for theoretical
reasons, however.)

  It's not very helpful.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-13 21:52 [Caml-list] Parsing cmi file bob zhang
  2012-03-13 22:36 ` Gerd Stolpmann
  2012-03-14  6:48 ` rixed
@ 2012-03-14 18:09 ` Richard W.M. Jones
  2012-03-14 18:14   ` Hongbo Zhang
  2 siblings, 1 reply; 14+ messages in thread
From: Richard W.M. Jones @ 2012-03-14 18:09 UTC (permalink / raw)
  To: bob zhang; +Cc: Caml List

On Tue, Mar 13, 2012 at 05:52:37PM -0400, bob zhang wrote:
> Hi list,
>    I noticed that Godi can pretty print cmi files, is there already
> libraries parsing cmi files?

cmigrep may be worth looking at.  It's also a nasty(-ish) hack since
it has to use the compiler sources.  I agree it would be nice to have
a formal API, but I can understand why the OCaml team wouldn't want to
have to maintain such a thing.

Rich.

-- 
Richard Jones
Red Hat

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-14 18:09 ` [Caml-list] " Richard W.M. Jones
@ 2012-03-14 18:14   ` Hongbo Zhang
  2012-03-14 19:44     ` Mehdi Dogguy
  2012-03-19 17:57     ` Richard W.M. Jones
  0 siblings, 2 replies; 14+ messages in thread
From: Hongbo Zhang @ 2012-03-14 18:14 UTC (permalink / raw)
  To: Richard W.M. Jones; +Cc: Caml List

On 3/14/12 2:09 PM, Richard W.M. Jones wrote:
> On Tue, Mar 13, 2012 at 05:52:37PM -0400, bob zhang wrote:
>> Hi list,
>>     I noticed that Godi can pretty print cmi files, is there already
>> libraries parsing cmi files?
> cmigrep may be worth looking at.  It's also a nasty(-ish) hack since
> it has to use the compiler sources.  I agree it would be nice to have
> a formal API, but I can understand why the OCaml team wouldn't want to
> have to maintain such a thing.
>
> Rich.
>
Thanks !
I tried, it does not compile, but it would be not hard to fix, I guess.

ocamlbrowser is unstable, it crashes every 2 hours(most times) on my 
computer

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-14 18:14   ` Hongbo Zhang
@ 2012-03-14 19:44     ` Mehdi Dogguy
  2012-03-19 17:57     ` Richard W.M. Jones
  1 sibling, 0 replies; 14+ messages in thread
From: Mehdi Dogguy @ 2012-03-14 19:44 UTC (permalink / raw)
  To: Hongbo Zhang; +Cc: Caml List

On 03/14/2012 07:14 PM, Hongbo Zhang wrote:
> I tried, it does not compile, but it would be not hard to fix, I
> guess.
> 

In Debian, we apply the following patches to compile it:

	http://patch-tracker.debian.org/package/cmigrep/1.5-9

FWIW, it compiles and runs perfectly well with any OCaml >= 3.10.

Regards,

-- 
Mehdi Dogguy مهدي الدڤي
http://dogguy.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Caml-list] Parsing cmi file
  2012-03-14 18:14   ` Hongbo Zhang
  2012-03-14 19:44     ` Mehdi Dogguy
@ 2012-03-19 17:57     ` Richard W.M. Jones
  1 sibling, 0 replies; 14+ messages in thread
From: Richard W.M. Jones @ 2012-03-19 17:57 UTC (permalink / raw)
  To: Hongbo Zhang; +Cc: Caml List

On Wed, Mar 14, 2012 at 02:14:12PM -0400, Hongbo Zhang wrote:
> On 3/14/12 2:09 PM, Richard W.M. Jones wrote:
> >On Tue, Mar 13, 2012 at 05:52:37PM -0400, bob zhang wrote:
> >>Hi list,
> >>    I noticed that Godi can pretty print cmi files, is there already
> >>libraries parsing cmi files?
> >cmigrep may be worth looking at.  It's also a nasty(-ish) hack since
> >it has to use the compiler sources.  I agree it would be nice to have
> >a formal API, but I can understand why the OCaml team wouldn't want to
> >have to maintain such a thing.
> >
> >Rich.
> >
> Thanks !
> I tried, it does not compile, but it would be not hard to fix, I guess.

Fedora carries some non-upstream patches (one taken from Debian) to
fix it:

http://pkgs.fedoraproject.org/gitweb/?p=ocaml-cmigrep.git;a=tree

There doesn't seem to be an active upstream at the moment.

Rich.

-- 
Richard Jones
Red Hat

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-03-19 17:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 21:52 [Caml-list] Parsing cmi file bob zhang
2012-03-13 22:36 ` Gerd Stolpmann
2012-03-13 23:20   ` bob zhang
2012-03-14  0:25     ` Gerd Stolpmann
2012-03-14 17:14       ` David Brown
2012-03-14  6:48 ` rixed
2012-03-14 17:30   ` [Caml-list] " Hongbo Zhang
2012-03-14 17:38     ` rixed
2012-03-14 17:49       ` Raphael Proust
2012-03-14 17:50       ` Dmitry Grebeniuk
2012-03-14 18:09 ` [Caml-list] " Richard W.M. Jones
2012-03-14 18:14   ` Hongbo Zhang
2012-03-14 19:44     ` Mehdi Dogguy
2012-03-19 17:57     ` Richard W.M. Jones

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).