[Caml-list] Define parser and printer consistently

2010-12-08 Thread Dawid Toton
I'm going to define a parser and a printer for a simple grammar. Is there a way to define both of them in a single construct using some existing OCaml tool? For example, I have a keyword function. The usual parser would contain a mapping like: function - `Function and the straightforward

[Caml-list] Re: Smart ways to implement worker threads

2010-07-16 Thread Dawid Toton
I find it odd that there is no Threaded_Queue module, a thread save version of Queue with 2 extra functions: (...) I use such a thread-safe queue a lot [1]. This is very simple yet universal enough. Honestly I can hardly remember using more elaborate constructs. Dawid [1]

[Caml-list] Re: Binding and evaluation order in module/type/value languages

2010-05-21 Thread Dawid Toton
It is not clear that this will work at all. The semantics of ocaml (contrary to SML) is not defined in terms of type generativity. This is great eureka to me. I thought that when the compiler refuses to unify some types it knows that they are incompatible (as the error message says). But

[Caml-list] Re: Phantom types

2010-05-17 Thread Dawid Toton
type 'a t = {l: float} Any thoughts ? I think the crucial question is when new record types are born. Here is my opinion: The = sign in the above type mapping definition is what I would call delayed binding. Early binding would be equivalent to type tmp = {lab : float} type 'a s = tmp

[Caml-list] Binding and evaluation order in module/type/value languages

2010-05-17 Thread Dawid Toton
Thinking about the discussion in the recent thread Phantom types [1], I have created the following piece of code that aims to demonstrate binding and evaluation order that takes effect in all three levels of OCaml. My question is: what are the precise rules is the case of type language? I have

[Caml-list] Binding and evaluation order in module/type/value languages

2010-05-17 Thread Dawid Toton
Thinking about the discussion in the recent thread Phantom types [1], I have created the following piece of code that aims to demonstrate binding and evaluation order that takes effect in all three levels of OCaml. My question is: what are the precise rules is the case of type language? I have

[Caml-list] Extending Set - strange behavior of abstract type

2010-04-27 Thread Dawid Toton
I tried to extend the standard Set module with new operations. I got error messages about type incompatibilities (the Set.S.t as exposed by my implementation and Set.S.t used by functions from the original Set). I have reduced my code to the following small example: module Set = struct

[Caml-list] Re: Module type of a structure returned by functor

2010-04-26 Thread Dawid Toton
I've found that I have more fundamental problem. What is the exact meaning of the following line? module type Foo = functor (X:X) - sig val foo : X.t end (1) Foo is not a functor, but it is a type of some functors that map modules to modules (2) Foo is a mapping from modules to module types

[Caml-list] Module type of a structure returned by functor

2010-04-23 Thread Dawid Toton
1. The following piece of code contains illegal constructs. These are functor applications marked with (* ? *). Basically, I need module type of what is produced by functor. My first question is: what is the proper, canonical workaround for unavailability of applications marked (* ? *)

Re: [Caml-list] OCaml on AIX

2010-01-27 Thread Dawid Toton
Christoph Bauer pisze: Please try: $ cd asmrun $ cpp -DSYS_aix power-aix.S power-aix.s $ as -u power-aix.s $ cd .. $ make opt Christoph Bauer Apparently I can go directly without preprocessor (and cpp I have on the AIX machine doesn't like asm syntax): $ cp power-aix.S power-aix.s $

Re: [Caml-list] Bytecode run on AIX - unknown C primitive error

2010-01-20 Thread Dawid Toton
unfortunatly I haven't a solution for the bytecode stuff. I only use ocaml with native compiled code. This works very well. Native code would also be sufficient (to save me from translating lot of code to C). The problem is that the assembler available on AIX doesn't unserstand

[Caml-list] Bytecode run on AIX - unknown C primitive error

2010-01-19 Thread Dawid Toton
I have installed part of this OCaml port http://home.arcor.de/chr_bauer/ocaml-aix.html on a computer running on AIX. It seems that everything built correctly except ocamlopt. So I have ocamlrun and standard library and this should be enough for bytecode to run. I have to build the bytecode on

[Caml-list] Re: Incremental linking

2009-10-16 Thread Dawid Toton
Yes. ocamlopt -pack actually calls ld -r underneath to consolidate several compilation units in a single .cmx/.o file. ld -r will resolve references between these compilation units. I tried with this switch and indeed I can link a toy program by arbitrary intermediate steps. It works OK and

[Caml-list] Incremental linking

2009-09-29 Thread Dawid Toton
I have lot of modules and they are compiled to native code. So I have .cmx and .o files and want to link them faster. Is is possible to make linking an associative operation acting on modules? I would like to do something like the following: Knowing the correct partial order of modules (that

[Caml-list] Incremental linking

2009-09-29 Thread Dawid Toton
I have lot of modules and they are compiled to native code. So I have .cmx and .o files and want to link them faster. Is is possible to make linking an associative operation acting on modules? I would like to do something like the following: Knowing the correct partial order of modules (that

[Caml-list] Broken dumps from memprof patch?

2009-06-08 Thread Dawid Toton
I have compiled MinGW port of the comopiler (3.10) with memprof patch applied. I can produce heap dumps, but heapstats tool fails to load it. I had to change major_gc.c, the line: #include unistd.h is replaced by a stub: int getpid() {return 8;} I had to tag all files in hp dir as precious

[Caml-list] Memory leak slowdown

2009-06-05 Thread Dawid Toton
I have an OCaml program using GTK running on Windows, using multiple threads. The overall memory usage grows significantly over time, but I don't know why. After it consumes several MB extra, it slows considerably and becomes unusable, so I have to fix this. Is it possible that this is

[Caml-list] Re: Memory leak slowdown

2009-06-05 Thread Dawid Toton
You might want to instrument the [caml_]register_global_root function and see how often it gets called. Is it possible to enable profiling in the compiler in Windows or Cygwin environment? Cygwin has gprof, but OCaml's configure script says 'no profiling'. Dawid

Re: [Caml-list] (Not) corrupt output of printf

2009-01-23 Thread Dawid Toton
This was actually a bug in GNOME Terminal... sorry for the noise. Dawid ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list:

Re: [Caml-list] (Not) corrupt output of printf

2009-01-23 Thread Dawid Toton
Weird ... I was going to suggeest it was because you weren't flushing the output after each print statement. This raises important question: Let's see the output as a sequence of bytes (there's no time). Assuming that the process exits normally and incompatible printing functions are not

[Caml-list] Corrupt output of printf

2009-01-22 Thread Dawid Toton
I have a program, which output is produced only with Printf.printf . This inner part is executed by another one (outer) using Unix.system . The outer executable uses print_endline before and after the inner is run. From time to time the output of the inner program is corrupt. Printf.printf

Re: [Caml-list] What is a future of ocaml?

2009-01-14 Thread Dawid Toton
Few days ago I spent some time googling for any info in the subject and found nothing (except assigned feature requests in the tracer). Would be great to know what should be expected about OCaml in a long term. I understand that there's no manpower to push the core compiler forward faster. But

[Caml-list] Toplevel - load cmo from given location

2009-01-09 Thread Dawid Toton
I've noticed stange behaviour: The following works OK (using #directory directive): #!/usr/bin/ocamlrun ocaml #directory /home/dt2/Calc1/CalcEngine/src/_build/extlib/ #load enum.cmo open Enum But this version not (using the full path directly): #!/usr/bin/ocamlrun ocaml #load

[Caml-list] Toplevel - loading dependencies

2009-01-09 Thread Dawid Toton
Another problem with loading modules in the toplevel: I need to use the module A. So I write: #load A.cmo to get a messsage Reference to undefined global B So I prepend a line: #load B.cmo and get another undefined global. Then it repeats prohibitively many times. This is resolving dependencies

Re: [Caml-list] Toplevel - load cmo from given location

2009-01-09 Thread Dawid Toton
The problem is that it gives Unbound module Enum while no error about loading the cmocmi is shown. The #directory instruction is needed to find the .cmi. I see, so there are 2 problems: * why the failure to load cmi is silent in this case? * why the toplevel fails to check for cmi where

Re: [Caml-list] Toplevel - loading dependencies

2009-01-09 Thread Dawid Toton
in case you're doing so this way: ocamlc -o my.cma mod1.ml mod2.ml mod3.ml mod4.ml this will recompile everything, but you can use in your makefile: (...) then you don't recompile everything, only the modified module Yes, with ocamlbuild I need not to recompile everything, but it's slow

Re: [Caml-list] Quantifier in the type

2008-10-17 Thread Dawid Toton
Hope this helps, Exactly what I wanted to know! Thanks! Dawid ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list:

Re: [Caml-list] Quantifier in the type

2008-10-16 Thread Dawid Toton
Thanks for your answer; now I'll try to sate my point in a clear way, since you misunderstood all my questions. I put 'a in the interface: val fu : 'a - 'a and int in the implementation: let fu x = x + 1 this interface doesn't reflect the implementation, ocaml will reject it in any way OK,

[Caml-list] Quantifier in the type

2008-10-15 Thread Dawid Toton
Just an elementary question. I put 'a in the interface: val fu : 'a - 'a and int in the implementation: let fu x = x + 1 So I have universal quantification: for any type 'a function fu can consume the argument. So my implementation doesn't comply with that universal quatification. And the

Re: [Caml-list] 'Nondeterministic' evaluation wrt exceptions

2008-07-25 Thread Dawid Toton
Thank you all for quick answers! Let me show an example of what I exactly mean. I start with a code: 1: let a = heavy 1 2: let b = heavy 2 3: let c = report (a + b) 4: let d = heavy 4 5: let e = heavy d Then I want to translate it automatically so that three applications of heavy are evaluated