caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] [ANN] Merlin 1.0 released
@ 2013-04-11 21:59 Frédéric Bour
  2013-04-12  1:14 ` Francois Berenger
  2013-04-12 16:01 ` [Caml-list] ocamlfind? how to compile Mr. Herr
  0 siblings, 2 replies; 10+ messages in thread
From: Frédéric Bour @ 2013-04-11 21:59 UTC (permalink / raw)
  To: caml-list

We are pleased to announce the first stable release of Merlin.

Merlin offers type analysis, scope-aware completion and interactive 
reporting of type and syntax errors directly inside your editor. Modes 
for Vim and Emacs are provided.
Efforts have been made to ease the integration of Merlin in existing 
projects: just specify source and build directories, any ocamlfind 
dependencies and enjoy assistance from your editor right now.

Install it directly from opam:
   $ opam install merlin

See it at work:
   https://github.com/def-lkb/merlin#screenshots

For other information, refers to the project page at 
https://github.com/def-lkb/merlin .

Merlin is only compatible with Ocaml 4.00.1, though it may work with 
newer versions.
All features except Camlp4 extensions are supported; specific support 
for Lwt and some type-conv syntax extensions is provided.

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

* Re: [Caml-list] [ANN] Merlin 1.0 released
  2013-04-11 21:59 [Caml-list] [ANN] Merlin 1.0 released Frédéric Bour
@ 2013-04-12  1:14 ` Francois Berenger
  2013-04-13 16:57   ` Frédéric Bour
  2013-04-12 16:01 ` [Caml-list] ocamlfind? how to compile Mr. Herr
  1 sibling, 1 reply; 10+ messages in thread
From: Francois Berenger @ 2013-04-12  1:14 UTC (permalink / raw)
  To: caml-list

Thanks for this tool! It looks quite interesting.

I have a tuareg menu in my Emacs.

Will there be a merlin one some day?

Thanks a lot,
F.

On 04/12/2013 06:59 AM, Frédéric Bour wrote:
> We are pleased to announce the first stable release of Merlin.
>
> Merlin offers type analysis, scope-aware completion and interactive
> reporting of type and syntax errors directly inside your editor. Modes
> for Vim and Emacs are provided.
> Efforts have been made to ease the integration of Merlin in existing
> projects: just specify source and build directories, any ocamlfind
> dependencies and enjoy assistance from your editor right now.
>
> Install it directly from opam:
>    $ opam install merlin
>
> See it at work:
>    https://github.com/def-lkb/merlin#screenshots
>
> For other information, refers to the project page at
> https://github.com/def-lkb/merlin .
>
> Merlin is only compatible with Ocaml 4.00.1, though it may work with
> newer versions.
> All features except Camlp4 extensions are supported; specific support
> for Lwt and some type-conv syntax extensions is provided.
>


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

* [Caml-list] ocamlfind? how to compile
  2013-04-11 21:59 [Caml-list] [ANN] Merlin 1.0 released Frédéric Bour
  2013-04-12  1:14 ` Francois Berenger
@ 2013-04-12 16:01 ` Mr. Herr
  2013-04-12 16:19   ` David Allsopp
  1 sibling, 1 reply; 10+ messages in thread
From: Mr. Herr @ 2013-04-12 16:01 UTC (permalink / raw)
  To: caml-list

Hi,

I did not understand how the helpers for compilation are supposed to work.

For example I have a script that executes external programs, and needs the Unix module.

For script execution I have in the top of my script: #load "unix.cma";;

This must be removed for ocamlc or ocamlopt to work, right? Annoying.

But how do I compile it without manually inserting "unix.cma"/"unix.cmxa" into the
command line? I thought the tools would do it.

This is what I tried:

strl@suse122-intel:~/Ocaml> ocamlfind ocamlc -o ml/unix2_exec ml/unix2_exec.ml
ocamlfind: [WARNING] The DLL dllpcre_stubs.so occurs in multiple directories:
/usr/lib64/ocaml/site-lib/pcre
ocamlfind: [WARNING] The DLL dllpcre_stubs.so occurs in multiple directories:
/usr/lib64/ocaml/stublibs
File "ml/unix2_exec.ml", line 1:
Error: Error while linking ml/unix2_exec.cmo:
Reference to undefined global `Unix'

/Str.

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

* RE: [Caml-list] ocamlfind? how to compile
  2013-04-12 16:01 ` [Caml-list] ocamlfind? how to compile Mr. Herr
@ 2013-04-12 16:19   ` David Allsopp
  2013-04-12 17:09     ` Mr. Herr
  2013-04-12 19:35     ` Mr. Herr
  0 siblings, 2 replies; 10+ messages in thread
From: David Allsopp @ 2013-04-12 16:19 UTC (permalink / raw)
  To: Mr. Herr, caml-list

Mr. Herr wrote:
> I did not understand how the helpers for compilation are supposed to work.
> 
> For example I have a script that executes external programs, and needs the
> Unix module.
> 
> For script execution I have in the top of my script: #load "unix.cma";;

Good "trick" for findlib is to add:
	#use "topfind"
to ~/.ocamlinit (create it, if necessary) and then in future toploops you just say
	#require "unix";;
instead. Useful when you start using packages which depend on other packages...

> This must be removed for ocamlc or ocamlopt to work, right? Annoying.

Yes and no - a way around it is to create a wrapper script for debugging in the toploop which loads all the required libraries (or just have libraries you usually need loaded via .ocamlinit). I think it's fairly unusual that you have something that's actively intended for both the toploop *and* separate compilation so it's usually just a matter of making debugging easier in the toploop with a little script.

> But how do I compile it without manually inserting "unix.cma"/"unix.cmxa"
> into the command line? I thought the tools would do it.
> 
> This is what I tried:
> 
> strl@suse122-intel:~/Ocaml> ocamlfind ocamlc -o ml/unix2_exec
> ml/unix2_exec.ml
> ocamlfind: [WARNING] The DLL dllpcre_stubs.so occurs in multiple
> directories:
> /usr/lib64/ocaml/site-lib/pcre
> ocamlfind: [WARNING] The DLL dllpcre_stubs.so occurs in multiple
> directories:
> /usr/lib64/ocaml/stublibs

These warnings look like your package manager is installing redundant files, but that won't be breaking anything.

> File "ml/unix2_exec.ml", line 1:
> Error: Error while linking ml/unix2_exec.cmo:
> Reference to undefined global `Unix'

ocamlfind ocamlc -o ml/unix2_exec -package unix -linkpkg ml/unix2_exec.ml

I have a feeling you may run into interesting issues compiling outside of the working directory, though, but I might be misremembering something...

If you add -verbose to any ocamlfind command then it will show you all the commands it's executing (which allows you to work out error messages from the compilers).

ocamlc command line is documented in Chapter 8 of the manual: http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual022.html
findlib docs for compiling and linking with packages: http://projects.camlcity.org/projects/dl/findlib-1.3.3/doc/guide-html/x115.html

HTH,


David

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

* Re: [Caml-list] ocamlfind? how to compile
  2013-04-12 16:19   ` David Allsopp
@ 2013-04-12 17:09     ` Mr. Herr
  2013-04-12 18:17       ` David Allsopp
  2013-04-12 19:35     ` Mr. Herr
  1 sibling, 1 reply; 10+ messages in thread
From: Mr. Herr @ 2013-04-12 17:09 UTC (permalink / raw)
  To: caml-list


Am 12.04.2013 18:19, schrieb David Allsopp:
> Mr. Herr wrote:
>> I did not understand how the helpers for compilation are supposed to work.
>>
>> For example I have a script that executes external programs, and needs the
>> Unix module.
>>
>> For script execution I have in the top of my script: #load "unix.cma";;
> Good "trick" for findlib is to add:
> 	#use "topfind"
> to ~/.ocamlinit (create it, if necessary) and then in future toploops you just say
> 	#require "unix";;
> instead. Useful when you start using packages which depend on other packages...
>

First try:

I added topfind to .ocamlinit, and in the interactive toplevel I see the startup
info, and I can enter [ #require "unix";; ],
but when I put [ #require "unix";; ] into my .ml file I get a syntax error on it:

str@suse122-intel:~/Ocaml/ml> ocaml unix2_exec.ml ls -l b\*
Unknown directive `require'.

Same error on compile with ocamlc. Sorry, I don't see how this is supposed to work.

/Str.


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

* RE: [Caml-list] ocamlfind? how to compile
  2013-04-12 17:09     ` Mr. Herr
@ 2013-04-12 18:17       ` David Allsopp
  2013-04-12 18:51         ` Mr. Herr
  0 siblings, 1 reply; 10+ messages in thread
From: David Allsopp @ 2013-04-12 18:17 UTC (permalink / raw)
  To: Mr. Herr, caml-list

Mr. Herr wrote:
> Am 12.04.2013 18:19, schrieb David Allsopp:
> > Mr. Herr wrote:
> >> I did not understand how the helpers for compilation are supposed to
> work.
> >>
> >> For example I have a script that executes external programs, and
> >> needs the Unix module.
> >>
> >> For script execution I have in the top of my script: #load
> >> "unix.cma";;
> > Good "trick" for findlib is to add:
> > 	#use "topfind"
> > to ~/.ocamlinit (create it, if necessary) and then in future toploops
> you just say
> > 	#require "unix";;
> > instead. Useful when you start using packages which depend on other
> packages...
> >
> 
> First try:
> 
> I added topfind to .ocamlinit, and in the interactive toplevel I see the
> startup info, and I can enter [ #require "unix";; ], but when I put [
> #require "unix";; ] into my .ml file I get a syntax error on it:

If you want to use findlib toploop directives in an ML file (i.e. invoked using ocaml Foo.ml) then you have to put [#use "topfind";;] into the .ml file as well (which is obviously only worthwhile if you have a lot of things to load). The script, presumably, /usr/lib64/ocaml/topfind contains the instructions necessary to make #require and so on work and .ocamlinit is only read if you invoke an interactive toploop (i.e. it's not read when you supply an input file on the command line).

> str@suse122-intel:~/Ocaml/ml> ocaml unix2_exec.ml ls -l b\* Unknown
> directive `require'.
> 
> Same error on compile with ocamlc. Sorry, I don't see how this is supposed
> to work.

It was just a tip for using findlib in the toploop! Note that all directives (anything beginning with a '#') are explicitly for ocaml and never ocamlc/ocamlopt.


David

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

* Re: [Caml-list] ocamlfind? how to compile
  2013-04-12 18:17       ` David Allsopp
@ 2013-04-12 18:51         ` Mr. Herr
  0 siblings, 0 replies; 10+ messages in thread
From: Mr. Herr @ 2013-04-12 18:51 UTC (permalink / raw)
  To: caml-list


Am 12.04.2013 20:17, schrieb David Allsopp:
> Mr. Herr wrote:
>> Am 12.04.2013 18:19, schrieb David Allsopp:
>>> Mr. Herr wrote:
>>>> I did not understand how the helpers for compilation are supposed to
>> work.
>>>> For example I have a script that executes external programs, and
>>>> needs the Unix module.
>>>>
>>>> For script execution I have in the top of my script: #load
>>>> "unix.cma";;
>>> Good "trick" for findlib is to add:
>>> 	#use "topfind"
>>> to ~/.ocamlinit (create it, if necessary) and then in future toploops
>> you just say
>>> 	#require "unix";;
>>> instead. Useful when you start using packages which depend on other
>> packages...
>>
>> First try:
>>
>> I added topfind to .ocamlinit, and in the interactive toplevel I see the
>> startup info, and I can enter [ #require "unix";; ], but when I put [
>> #require "unix";; ] into my .ml file I get a syntax error on it:
> If you want to use findlib toploop directives in an ML file (i.e. invoked using ocaml Foo.ml) then you have to put [#use "topfind";;] into the .ml file as well (which is obviously only worthwhile if you have a lot of things to load). The script, presumably, /usr/lib64/ocaml/topfind contains the instructions necessary to make #require and so on work and .ocamlinit is only read if you invoke an interactive toploop (i.e. it's not read when you supply an input file on the command line).
>
>> str@suse122-intel:~/Ocaml/ml> ocaml unix2_exec.ml ls -l b\* Unknown
>> directive `require'.
>>
>> Same error on compile with ocamlc. Sorry, I don't see how this is supposed
>> to work.
> It was just a tip for using findlib in the toploop! Note that all directives (anything beginning with a '#') are explicitly for ocaml and never ocamlc/ocamlopt.
>
>

Thanks, one little step...

/Str.


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

* Re: [Caml-list] ocamlfind? how to compile
  2013-04-12 16:19   ` David Allsopp
  2013-04-12 17:09     ` Mr. Herr
@ 2013-04-12 19:35     ` Mr. Herr
  2013-04-14  9:31       ` AW: " Gerd Stolpmann
  1 sibling, 1 reply; 10+ messages in thread
From: Mr. Herr @ 2013-04-12 19:35 UTC (permalink / raw)
  To: caml-list


Am 12.04.2013 18:19, schrieb David Allsopp:
> Mr. Herr wrote:
>> I did not understand how the helpers for compilation are supposed to work.
>>
>> For example I have a script that executes external programs, and needs the
>> Unix module.
>>
>> For script execution I have in the top of my script: #load "unix.cma";;
> Good "trick" for findlib is to add:
> 	#use "topfind"
> to ~/.ocamlinit (create it, if necessary) and then in future toploops you just say
> 	#require "unix";;
> instead. Useful when you start using packages which depend on other packages...
>
>> This must be removed for ocamlc or ocamlopt to work, right? Annoying.
> Yes and no - a way around it is to create a wrapper script for debugging in the toploop which loads all the required libraries (or just have libraries you usually need loaded via .ocamlinit). I think it's fairly unusual that you have something that's actively intended for both the toploop *and* separate compilation so it's usually just a matter of making debugging easier in the toploop with a little script.
>
The response goes to the list...

I am using a lot of scripting, and you could perfectly well execute the ml scripts
with a #!/usr/bin/ocaml line on top. The idea is that scripts are not "finished"
(or less finished, and not documented) compared to programs, and that you read and
adjust the source to your instant need. 

My findings say that scripted ml is only a little bit slower than bytecode, but has a
bigger memory requirement. This matches or is better than a lot of _very_
popular scripting languages. Additionally you can compile, even to native code.

If only it was not so unfinished. I am just writing exec functions, it should be
rather easy to capture "Reference to undefined global `Unix' " and repair it.

Has this not been done?? What is ocamlfind for?


/Str.

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

* Re: [Caml-list] [ANN] Merlin 1.0 released
  2013-04-12  1:14 ` Francois Berenger
@ 2013-04-13 16:57   ` Frédéric Bour
  0 siblings, 0 replies; 10+ messages in thread
From: Frédéric Bour @ 2013-04-13 16:57 UTC (permalink / raw)
  To: Francois Berenger; +Cc: caml-list

On 12/04/2013 03:14, Francois Berenger wrote:
> Thanks for this tool! It looks quite interesting.
Thanks for your interest!
> I have a tuareg menu in my Emacs.
>
> Will there be a merlin one some day?
>
> Thanks a lot,
> F.

In fact, the Emacs mode is a (significant) external contribution and I
don't know enough about Emacs to be of any help.

However, you're invited to open an issue on the github tracker :).


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

* AW: [Caml-list] ocamlfind? how to compile
  2013-04-12 19:35     ` Mr. Herr
@ 2013-04-14  9:31       ` Gerd Stolpmann
  0 siblings, 0 replies; 10+ messages in thread
From: Gerd Stolpmann @ 2013-04-14  9:31 UTC (permalink / raw)
  To: Mr. Herr; +Cc: caml-list

Am 12.04.2013 21:35:36 schrieb(en) Mr. Herr:
> 
> Am 12.04.2013 18:19, schrieb David Allsopp:
> > Mr. Herr wrote:
> >> I did not understand how the helpers for compilation are supposed  
> to work.
> >>
> >> For example I have a script that executes external programs, and  
> needs the
> >> Unix module.
> >>
> >> For script execution I have in the top of my script: #load  
> "unix.cma";;
> > Good "trick" for findlib is to add:
> > 	#use "topfind"
> > to ~/.ocamlinit (create it, if necessary) and then in future  
> toploops you just say
> > 	#require "unix";;
> > instead. Useful when you start using packages which depend on other  
> packages...
> >
> >> This must be removed for ocamlc or ocamlopt to work, right?  
> Annoying.
> > Yes and no - a way around it is to create a wrapper script for  
> debugging in the toploop which loads all the required libraries (or  
> just have libraries you usually need loaded via .ocamlinit). I think  
> it's fairly unusual that you have something that's actively intended  
> for both the toploop *and* separate compilation so it's usually just  
> a matter of making debugging easier in the toploop with a little  
> script.
> >
> The response goes to the list...
> 
> I am using a lot of scripting, and you could perfectly well execute  
> the ml scripts
> with a #!/usr/bin/ocaml line on top. The idea is that scripts are not  
> "finished"
> (or less finished, and not documented) compared to programs, and that  
> you read and
> adjust the source to your instant need.
> 
> My findings say that scripted ml is only a little bit slower than  
> bytecode,

It should be exactly the same speed. The same bytecode interpreter is  
running.

> but has a
> bigger memory requirement. This matches or is better than a lot of  
> _very_
> popular scripting languages. Additionally you can compile, even to  
> native code.
> 
> If only it was not so unfinished. I am just writing exec functions,  
> it should be
> rather easy to capture "Reference to undefined global `Unix' " and  
> repair it.

This is just not the way it is supposed to work. OCaml is primarily a  
compiler language, and scripting only an add-on mode, which is mainly  
useful for testing, or as driver, but not really beyond that.

The best you can do here with standard utilities is to split your  
script into two files:

- One "loader" that contains the scripting directives to load
   everything, e.g.

   #use "topfind";;
   #require "unix";;
   #use "impl.ml";;

- The real implementation (impl.ml) not using any directives. This
   implementation can be independently compiled with ocamlc or ocamlopt.

> Has this not been done?? What is ocamlfind for?

ocamlfind is only a wrapper around the compiler, basically it  
translates -package options into the list of compiler switches requires  
to link a package. ocamlfind cannot change the language.

See also the discussion here:

https://ocaml.janestreet.com/?q=node/80

Maybe Martin's utility ocamlscript is also useful for you:

http://mjambon.com/ocamlscript.html

Gerd

> 
> 
> /Str.
> 
> --
> 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
> 
> 



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

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

end of thread, other threads:[~2013-04-14  9:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 21:59 [Caml-list] [ANN] Merlin 1.0 released Frédéric Bour
2013-04-12  1:14 ` Francois Berenger
2013-04-13 16:57   ` Frédéric Bour
2013-04-12 16:01 ` [Caml-list] ocamlfind? how to compile Mr. Herr
2013-04-12 16:19   ` David Allsopp
2013-04-12 17:09     ` Mr. Herr
2013-04-12 18:17       ` David Allsopp
2013-04-12 18:51         ` Mr. Herr
2013-04-12 19:35     ` Mr. Herr
2013-04-14  9:31       ` AW: " Gerd Stolpmann

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