Re: [Caml-list] [ANN] findlib-1.3.0

2012-05-07 Thread Gabriel Scherer
Thanks for the good work! Just a remark: I have sometimes considered sending a bug report for findlib (actually each time the bug was in another place), and did not know where to send them. On the (otherwise excellently polished) camlcity wepages there is never any mention of a bug reporting

Re: [Caml-list] reuse of abstract types

2012-05-07 Thread Gabriel Scherer
Now I want to design a module Q, with operations using type t. To refer to t in the signature of Q, I am obliged to declare a module Mt : MT inside the signature module type QT = sig  module Mt : MT  val g : Mt.t - end I don't believe this is the way to go. You could either: 1.

Re: [Caml-list] How do I declare a value of 'a t instead of '_a t in a module?

2012-05-06 Thread Gabriel Scherer
-...@web.de wrote: Gabriel Scherer gabriel.sche...@gmail.com writes: You need to specify in the signature that ('a t) is contravariant:   type +'a t Thanks, that was what I was looking for. Why can I never find this in the docs when I need it? :) MfG        Goswin -- Caml-list mailing list

Re: [Caml-list] A shallow option type

2012-05-05 Thread Gabriel Scherer
Is it possible to somehow declare the constraint that 'a in 'a shallow must not be itself a 'b shallow? If I understand correctly, this is not possible directly, and while you could do that with a sufficiently clever layer of phantom types, I'm not sure it is worth the additional complexity. In

Re: [Caml-list] How do I declare a value of 'a t instead of '_a t in a module?

2012-05-05 Thread Gabriel Scherer
You need to specify in the signature that ('a t) is contravariant: type +'a t This is done to please the relaxed value restriction: in the let-binding let foo = make_null (), the right-hand-side is not a value, so it is not generalized (this is the value restriction). The relaxation introduced

Re: [Caml-list] A shallow option type

2012-05-05 Thread Gabriel Scherer
Thanks for the clearer use-case example. I think Andreas's comment is at a general level of language design: no, we don't want to add something close to what you're asking for in a language. His argumentation is spot on. What we could have is a type system with strong update, but that's dreaming

Re: [Caml-list] using infix operators/functions in modules when not using open

2012-04-27 Thread Gabriel Scherer
Module.(foo (op) bar) This is a local open (a more explicit notation is let open Module in foo op bar). I think this is a fine solution: I don't like open, but local mitigates its flaws. Another solution is to rebind your operator locally: let (op) = Module.blah in foo op bar (of course

Re: [Caml-list] Printexc.register_printer without catch

2012-04-13 Thread Gabriel Scherer
It seems Printexc.register_printer affects the other Printexc.* functions, not the way the toplevel itself (or the runtime system more generally) handles uncaught exceptions. # Printexc.register_printer begin function Not_found - Some hello | _ - None end;; - : unit = () # (fun () - raise

[Caml-list] Re: Variance of GADT parameters

2012-04-13 Thread Gabriel Scherer
Dear list, I'm afraid my last e-mail was rejected because it was too long. This is probably a good indication that it would be too long for you as well, but for the record I have uploaded the email content and the attached technical development:

Re: [Caml-list] [ANN] ocamlopen 1.0.2

2012-04-12 Thread Gabriel Scherer
Is there a description somewhere of the semantics of your language change? More specifically: 1. You link to a paper by Andres Löh and Ralf Hinze, how close are you of their proposal? They mention open datatypes and functions, you propose open datatypes, but not open functions? That would be

Re: [Caml-list] Articles on using types for enhancing sw-quality?

2012-04-09 Thread Gabriel Scherer
In the next OCaml version, you will be able to do that more cleanly with GADTs. That is actually one of the advantages of having GADTs in the language; while the typing effects can be (more or less awkwardly) encoded in existing constructions, such encodings tends to rely on higher-order

Re: [Caml-list] Articles on using types for enhancing sw-quality?

2012-04-07 Thread Gabriel Scherer
In the ML-type-system community, enforcing invariant through typing has mostly been discussed, as far as I'm aware, informally, and is part of the language communities folklore. There have been publications centered on the use of richer features (than the base ML type systems), with examples that

Re: [Caml-list] Strategies for finding memory leaks

2012-04-04 Thread Gabriel Scherer
May your program leak one of those GTK resources? The effectiveness of your patch seems to indicate that you have a lot of one of these values allocated (and that they were requesting the GC much too frequently). The patch solves the CPU usage induced by additional GC, but does not change the

Re: [Caml-list] How could I implement an efficient ring buffer?

2012-04-02 Thread Gabriel Scherer
A small implementation of a FIFO queue implemented as a circular buffer of fixed length: type 'a circular_buffer = { mutable pos : int; mutable count : int; data : 'a array; size : int; } let create size dummy = { pos = 0; count = 0; data = Array.make size dummy; size; } let

Re: [Caml-list] Broken link in Module Format doc

2012-03-28 Thread Gabriel Scherer
I suppose the bugtracker is a good choice, as long as you set the category (Caml web site or OCaml documentation according to whether it's part of a full-blown document or about the website navigation) and severity (text) accordingly. On Wed, Mar 28, 2012 at 1:53 PM, Ricardo Catalinas Jiménez

Re: [Caml-list] Funny name for a type variable in the output: should this be filed on the BTS?

2012-03-23 Thread Gabriel Scherer
the polymorphism for polymorphic recursion.) On Fri, Mar 23, 2012 at 7:45 AM, Jacques Garrigue garri...@math.nagoya-u.ac.jp wrote: On 2012/03/23, at 14:52, Gabriel Scherer wrote: However, as you already mentioned, the original type itself was erroneous. So a better solution would be to get an error

Re: [Caml-list] JavaScript parser?

2012-03-22 Thread Gabriel Scherer
Aurochs is still available on Berke Durak's github: https://github.com/berke/aurochs Aurochs is only a parser generator; it was used to write a Javascript grammar for the tool Jsure (also developped by Berke): https://github.com/berke/jsure On Thu, Mar 22, 2012 at 12:34 PM, Alan Schmitt

Re: [Caml-list] Insufficient polymorphism in local let.

2012-03-22 Thread Gabriel Scherer
This is a consequence of value restriction, with a direct workaround. See the FAQ: A function obtained through partial application is not polymorphic enough http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion let get1 a b = let must x = lmust get2 x in On Fri,

Re: [Caml-list] Funny name for a type variable in the output: should this be filed on the BTS?

2012-03-22 Thread Gabriel Scherer
However, as you already mentioned, the original type itself was erroneous. So a better solution would be to get an error at that point. Namely, if the type annotation contains a type variable with the same name as one of the quantified types. Does it sound reasonable. I'd rather use a

Re: [Caml-list] Wanted: GADT examples: string length, counting module x

2012-03-19 Thread Gabriel Scherer
I suspect you're seeing too much into the GADT as they're being added in OCaml. Your examples are not basically about GADTs, but about dependent types: you want to encode values (and operations on them) at the type level to get more expressivity. This is a well-known and extremely powerful trend

Re: [Caml-list] a question about ocamlopt and ocamldep

2012-03-14 Thread Gabriel Scherer
:-( I don't understand. Why is it sad to have the *ability* to perform cross-module implementation-dependent optimizations (at the inevitable cost of locally damaging separate compilation) *if* you wish? On Wed, Mar 14, 2012 at 11:31 AM, Matej Košík 5764c029b688c1c0d24a2e97cd7...@gmail.com

Re: [Caml-list] Arrays and private types

2012-03-14 Thread Gabriel Scherer
Here is a proposal: https://gitorious.org/gasche-snippets/private-array-keys-type/blobs/master/private_array_key_types.ml It works by using a functor to generate fresh private types for keys. Note that the arrays themselves are still polymorphic (no IntArray FloatArray etc.). The user still

Re: [Caml-list] Very slow compilation

2012-03-11 Thread Gabriel Scherer
I can't comment on the type-checker internals, but a general first step would be to make sure that you don't recompile things that you don't need to. If you change the *implementation* of a module without changing its interface, you should not have to recompile any other module, at least when

Re: [Caml-list] Can one implement greedy/inline data structures in ocaml?

2012-03-09 Thread Gabriel Scherer
think learning *not to use* fancy features is just as fun as using them. On Fri, Mar 9, 2012 at 8:50 AM, Goswin von Brederlow goswin-...@web.de wrote: Gabriel Scherer gabriel.sche...@gmail.com writes: I have implemented a small example in two versions: one with external dllist (I'm using

Re: [Caml-list] Can one implement greedy/inline data structures in ocaml?

2012-03-08 Thread Gabriel Scherer
: https://gitorious.org/gasche-snippets/outside-or-inline-lists/blobs/master/goswin_dllists.ml On Thu, Mar 8, 2012 at 6:11 AM, Goswin von Brederlow goswin-...@web.de wrote: Gabriel Scherer gabriel.sche...@gmail.com writes: So then you need mutable option types or mutables that you initialize

Re: [Caml-list] state of native dynlink on os x

2012-03-08 Thread Gabriel Scherer
This error is not Mac-related (I can reproduce it on my Debian). I believe it is a result from the link-by-need semantics of the .cma and .cmxa: loader.ml does not explicitly depend on test, so when producing the executable test.cmxa isn't linked (modules included .cm{x,}a, contrarily to .cm{x,o},

Re: [Caml-list] concerning using of `deriving' syntactic plugin

2012-03-07 Thread Gabriel Scherer
You can inject the definition you want in the following way: module Meths = struct include Meths module Show_t = ... end type value_kind = ... deriving (Show) This works because deriving, being a Camlp4 extension, does not refer to the module Meths, but any module Meths that is

Re: [Caml-list] Can one implement greedy/inline data structures in ocaml?

2012-03-07 Thread Gabriel Scherer
So then you need mutable option types or mutables that you initialize with dummy values and then overwrite with the real thing once all members of a cycle are created. Or some other trickery to make it work. Overall cycles are generally not good. I believe the trick you need (either passing a

[Caml-list] [community poll for PR#5312] Do some OCaml Windows users still use the @responsefile feature?

2012-03-05 Thread Gabriel Scherer
In the process of discussing bug #5312, the caml team would like to know if people still have use of the @responsefile feature under windows. If not, it could be removed from the runtime -- that is from all OCaml programs. http://caml.inria.fr/mantis/view.php?id=5312 @responsefile is a

Re: [Caml-list] [community poll for PR#5312] Do some OCaml Windows users still use the @responsefile feature?

2012-03-05 Thread Gabriel Scherer
interface. On Mon, Mar 5, 2012 at 2:46 PM, Jeff Schultz j...@csse.unimelb.edu.au wrote: On Mon, Mar 05, 2012 at 11:46:08AM +0100, Gabriel Scherer wrote: According to our Windows spies, the command-line restrictions are nowadays very reasonable: 8K for cmd.com, and 32K internally. Maybe

Re: [Caml-list] [community poll for PR#5312] Do some OCaml Windows users still use the @responsefile feature?

2012-03-05 Thread Gabriel Scherer
to contact the authors, or ask the caml-list. http://protz.github.com/ocaml-installer/ http://caml.inria.fr/mantis/my_view_page.php On Mon, Mar 5, 2012 at 4:10 PM, Jeff Schultz j...@csse.unimelb.edu.au wrote: On Mon, Mar 05, 2012 at 03:31:55PM +0100, Gabriel Scherer wrote: It looks to me like you

Re: [Caml-list] types not equal when I expect them to be

2012-03-01 Thread Gabriel Scherer
Note that Bar is actually unnecessary. The following code exhibit the exact same behavior: module Foo = struct module St = struct type t = string let compare = compare end module Map (* : Map.S with type key = St.t *) = Map.Make(St) (* module Map = Map.Make(struct type t =

Re: [Caml-list] Re: module type of on sub-module of functor result

2012-02-23 Thread Gabriel Scherer
On Thu, Feb 23, 2012 at 12:17 AM, Jacques Garrigue garri...@math.nagoya-u.ac.jp wrote: On 2012/02/23, at 3:49, Andreas Rossberg wrote: On Feb 22, 2012, at 18.24 h, Gabriel Scherer wrote: [A(B)] and  [A.B] are syntacticly valid module_expr's but [A(B).C] isn't. Is this because of an inherent

Re: [Caml-list] Re: module type of on sub-module of functor result

2012-02-22 Thread Gabriel Scherer
You could use the following work-around, which introduces an additional layer to have some space to name the functor application: module Map = struct module Make (Ord : BatInterfaces.OrderedType) = struct module M = BatMap.Make(Ord) module Result : module type of M.Labels =

Re: [Caml-list] Some utilities about camlp4

2012-02-21 Thread Gabriel Scherer
I had trouble being sure what meta filter you were talking about. Here's what I found out, in case other people on the list wondered the same: the meta part of Camlp4 is about turning a value into a piece of OCaml AST representing the syntax of this value. The meta filter is a kind of type-conv

Re: [Caml-list] Fwd: Re: [Batteries-devel] browsing the code while reading the doc

2012-02-15 Thread Gabriel Scherer
My mistake, I wasn't aware or had forgotten this -- very useful indeed -- feature. Thanks, Vincent and Maxence, for the correction. (Gabriel; sometimes bluestorm, for historical reasons, and often gasche.) On Wed, Feb 15, 2012 at 9:44 AM, Maxence Guesdon maxence.gues...@inria.fr wrote: Hello,

Re: [Caml-list] What am I reinventing here?

2012-02-14 Thread Gabriel Scherer
.v with A - () | B - () (* works *) In your case, you should write (module Make(O : Ops) : S with type foo = ... and bar = ...). On Tue, Feb 14, 2012 at 11:24 AM, Andre Nathan an...@digirati.com.br wrote: On Tue, 2012-02-14 at 11:09 +0100, Gabriel Scherer wrote: Here is an attempt at a functor

[Caml-list] Re: Variance of GADT parameters

2012-02-12 Thread Gabriel Scherer
-u.ac.jp wrote: On 2012/02/10, at 19:11, Gabriel Scherer wrote: I've been playing with GADTs and noticed that the condition on parameter variance is very restrictive. The two following examples fail:   type +_ const =   | Const : int - int expr   type +_ expr =   | Const : 'a - 'a expr

Re: [Caml-list] syntactic detail

2012-02-08 Thread Gabriel Scherer
There is no purpose, it's just an edge case of the simple lexical specification you can find at: http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#float-literal Everywhere digits are allowed, you can insert extraneous underscores. There is no restriction that there must be at least one digit

Re: [Caml-list] syntactic detail

2012-02-08 Thread Gabriel Scherer
People. Please. Tell me you are *not* arguing over underscores in numeric literals ! But it hides bugs, because if you see 10_000_ you are much more likely to think it is 10^7 than you are with 1, where you are likely to be careful and take your time. So your point is : it is

Re: [Caml-list] What type strategy ?

2012-02-02 Thread Gabriel Scherer
I did not understand the whole picture of your question, but I think I get the idea. You are looking for a way to manipulate an heterogeneous set of values that have a common interface (possibly a common subset of their interface), but may have different internal representations. Your current

Re: [Caml-list] how (within camlp4 printer) can I traverse AST ?

2012-02-02 Thread Gabriel Scherer
...@gmail.com wrote: On 01/31/2012 10:58 PM, Gabriel Scherer wrote: Sig.Ast is the most general structure available, that you use if you want to manipulate any kind of grammar for Camlp4. If you know the AST you're manipulating corresponds to an OCaml program, you should use the more specific

Re: [Caml-list] SQL engine in OCaml with client side cache

2012-01-30 Thread Gabriel Scherer
You don't seem to like SQL much, which is surprising as it is kind of isomorphic to comprehension of sets (of tuples). That's why F# added first class SQL support with comprehension-like syntax http://msdn.microsoft.com/en-us/library/hh225374(v=vs.110).aspx This may be a little off-topic

Re: [Caml-list] pattern matching on integer intervals

2012-01-21 Thread Gabriel Scherer
I believe your best bet is the 'if .. then .. else' chain. You may also use 'when' clauses in pattern matching, but those don't scale too well and are best avoided if their are the only content of your content: pattern matching are good for structural deconstruction and environment binding, but

Re: [Caml-list] inconsistent assumptions over interface [...]

2012-01-16 Thread Gabriel Scherer
This means that biocaml and batteries interface with different compiled versions of BatLogger. The solution is most likely to recompile on biocaml's side, so that it gets uptodate with batteries-side change. Assuming, of course, that you use Batteries's BatLogger directly instead of duplicating

Re: [Caml-list] web link to the two glmlite patches for OSX

2012-01-14 Thread Gabriel Scherer
we miss a reStructuredText equivalent in OCaml, amazing how you can push something online on the web in 5 minutes. I'm not exactly sure what you mean by that. As markup formatters are relatively self-contained programs, it's easy to use tools written in basically any language (you don't even

Re: [Caml-list] References and polymorphism

2012-01-10 Thread Gabriel Scherer
For a description of how the value restriction is relaxed in the OCaml type system, see the article Relaxing the value restriction, by Jacques Garrigue, 2004 http://caml.inria.fr/about/papers.en.html On Tue, Jan 10, 2012 at 6:20 PM, David Allsopp dra-n...@metastack.com wrote: Dario Teixeira

Re: [Caml-list] Examples where let rec is undesirable

2012-01-03 Thread Gabriel Scherer
What I am wondering is why type definitions are recursive by default. It is mostly troubling for beginners. Indeed, it is a defect of the language not to have non-recursive type definitions. My usual reference on this topic is Yaron's complaint: https://ocaml.janestreet.com/?q=node/25 The

Re: [Caml-list] working %.pp.ml target with ocamfind/ocamlbuild

2011-12-31 Thread Gabriel Scherer
I was also under the impression that ocamlbuild Ocamlfind integration was unable to use archive(syntax) or archive(preprocessor) dependencies for ocamlfind packages providing syntax extensions. This is a serious limitation as it makes some ocamlfind packages unusable. If you're considering

Re: [Caml-list] Some simple(?) questions about camlp4 :quotations ...

2011-12-28 Thread Gabriel Scherer
(1) Is any other syntax available for quotations apart from :foo ... and the default quotation expander ... ? No. That said, you could implement your own quotations mechanism as a Camlp4 extension (changing the grammar of the language). The benefit of the official quotations is that you don't

Re: [Caml-list] Some comments on recent discussions

2011-12-14 Thread Gabriel Scherer
As for the build systems, I'd advise everyone to use OASIS instead of custom systems: it's not perfect on windows but for cairo2 and archimedes, I think I only had to change paths from backward-slashes to forward-slashes in setup.data (or the other way round) (took 15 seconds). A

Re: [Caml-list] Camlp4/p5 type reflection [was: OCaml maintenance status / community fork (again)]

2011-12-11 Thread Gabriel Scherer
wrote: Le 11/12/2011 00:34, Gabriel Scherer a écrit : The original Camlp4 tool was mostly developped by Daniel de Rauglaudre. [...] (I'm thinking of eg. Martin Jambon, which had extensive Camlp4 extensions, and the Coq team which has user-defined notations using Camlp4 and, huh, I really don't

Re: [Caml-list] Camlp4/p5 type reflection [

2011-12-11 Thread Gabriel Scherer
. Evidently other people have a different opinion, and that's fine. On Sun, Dec 11, 2011 at 1:47 AM, Wojciech Meyer wojciech.me...@googlemail.com wrote: Gabriel Scherer gabriel.sche...@gmail.com writes: A summary to this lengthy mail: (1) Why type-enriched Camlp4 is an unreasonable idea (2) We

Re: [Caml-list] Camlp4/p5 type reflection [was: OCaml maintenance status / community fork (again)]

2011-12-11 Thread Gabriel Scherer
, and it would be clear that it is a bit behind with the newest syntactical features. Also, it could be developed outside the core team. Gerd Am Sonntag, den 11.12.2011, 11:29 +0100 schrieb Gabriel Scherer: And Xavier's mail suggests that camlp4 is a maintenance burden for the OCaml team. Why

Re: [Caml-list] Why isn't there a common platform for functional language interaction ?

2011-12-10 Thread Gabriel Scherer
There already exist such a common denominator language. For performance reasons, it is architecture-dependent (I mean there are several dialects to better use hardware peculiarities; the virtual machine it runs on is not exactly virtual). Unfortunately, most languages have concentrated on

[Caml-list] how could the community help with Oasis-DB; towards a CPAN for OCaml?

2011-12-10 Thread Gabriel Scherer
Edgar, It's excellent to know that you have some knowledge of Oasis-DB. I share the common assumption that this is one of the missing bricks of the OCaml ecosystem, and I hope the community at large can help with it. I asked Sylvain about it a few months ago, but he wasn't sure at that time what

Re: [Caml-list] Camlp4/p5 type reflection [was: OCaml maintenance status / community fork (again)]

2011-12-10 Thread Gabriel Scherer
A summary to this lengthy mail: (1) Why type-enriched Camlp4 is an unreasonable idea (2) We should extract the typedtree; why it's hard (3) A fictional narrative of the camlp4/camlp5 history (4) Why you don't want to become Camlp4 maintainer (5) How we could try not to use Camlp4 in the future (6)

Re: [Caml-list] Why NOT to compile OCaml via C

2011-12-09 Thread Gabriel Scherer
I find the idea of making ocamlopt a GCC (or LLVM) frontend the most sensible and constructive one I've seen in these discussions. Note that, besides Oleg excellent description of some issues, the idea has already been discussed a few times before, here and on llvm-dev: -

Re: [Caml-list] Why NOT to compile OCaml via C

2011-12-09 Thread Gabriel Scherer
-Clang-centric project. I think your patches could bring value to LLVM, independently of the success of the ambitious ocaml backend attempt. On Fri, Dec 9, 2011 at 1:08 PM, Benedikt Meurer benedikt.meu...@googlemail.com wrote: On Dec 9, 2011, at 10:58 , Gabriel Scherer wrote: I find the idea

Re: [Caml-list] Generic printer patch

2011-12-08 Thread Gabriel Scherer
Martin, in the meantime, you can use Extlib's (Std.dump : 'a - string) function, which is also integrated into Batteries. `dump` does not require any modification to the compiler or toolchain. For those that are not familiar with it, 'dump' uses the low-level representation of OCaml values to

Re: [Caml-list] Some comments on recent discussions

2011-12-07 Thread Gabriel Scherer
The French book Le langage Caml is very great, althought it is quite old, and althought examples used in the book (write a pascal compiler, a grep tool and so on) is maybe too theoristic for engineer target. Maybe a translation would be sufficient ? ( For those interested, the book is

Re: [Caml-list] OCaml maintenance status / community fork

2011-12-06 Thread Gabriel Scherer
I would like to comment on a tangential aspect of the rationale you gave: Given that OCaml is such a nice language with a lot of useful frameworks available, it is too sad to see it loosing ground just because of it's closed development process and lack of time of the official team. I

Re: [Caml-list] 3.13.0 stricter on interfaces? (building extlib)

2011-11-26 Thread Gabriel Scherer
There is a slighlt misinterpretation in your analysis of the issue: the problem comes from the fact that OCaml 3.13 standard library has added a ?seed optional parameter to the Hashtbl.create method. Extlib's interface still assumes =3.12 interface with no parameter (and in particular didn't

Re: [Caml-list] Deleting a type alias while including a module

2011-11-24 Thread Gabriel Scherer
Here is how I understand the situation: module type XARRAY = sig type 'a xarray type 'a t = 'a xarray end (XArray : XARRAY with type 'a t := 'a XArray.xarray ) Type declarations do not match: type 'a t = 'a XArray.xarray is not included in type 'a t = 'a

[Caml-list] Jump-to-definition and type-aware completion for Caml (was : Argot 1.0 release)

2011-11-04 Thread Gabriel Scherer
But having been recently forced out of emacs into a proprietary IDE to be *able* to work on a project written in a programmingLanguageWithAbsurdlyLongNamingConventions, one thing I actually became very fond of is type aware autocompletion and the ability to browse from a symbol in my code

Re: [Caml-list] How to write an efficient interpreter

2011-10-24 Thread Gabriel Scherer
Even staying at the interpreter stage, you can probably improve your performance seriously by being careful about your implementation : use efficient data structure (what is your implementation of variable lookup?), avoid unnecessary allocation, use tail-recursive functions where possible, etc.

Re: [Caml-list] Interpreting a language with (sparse) arrays explicitly indexed

2011-10-18 Thread Gabriel Scherer
What about hash tables ? | Val_table of (value, value) Hashtbl.t If you have caml closures in your values (not in Val_closure but in Val_primitive), it is maybe not appropriate to use the default hash function that would choke on them. You should rather define your own hashing function --but

Re: [Caml-list] Ocaml: typing by name vs. typing by structure

2011-10-16 Thread Gabriel Scherer
If record were structurally typed, there would be an ambiguity as to, for example, what this function mean: let access_foo t = t.foo What would the type of `access_foo` be ? { foo : 'a } - 'a ? { foo : 'a; bar : 'b } - 'a ? Should `access_foo { foo = 1 }` be typable? And `access_foo { foo = 1;

Re: [Caml-list] with clause

2011-10-09 Thread Gabriel Scherer
The with type foo = ... construct is meant to be used on signatures (module interfaces), not on structures (module implementations). First, a remark: if you want to share code, it's not terribly comfortable if it's split into three different files of five lines each. You could put your three

Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Gabriel Scherer
In my experience, the OCaml code doing recursive call and pattern matching is a relatively bad way to reason about such rewrite systems. Your questions are extremely pertinent, and relatively difficult to answer in general. For a start, I think your code indeed repeats useless traversals. This

Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Gabriel Scherer
(Constant 6., Variable X)) On Sun, Oct 2, 2011 at 6:48 PM, Gabriel Scherer gabriel.sche...@gmail.com wrote: On Sun, Oct 2, 2011 at 6:32 PM, Xavier Leroy xavier.le...@inria.fr wrote: NBE is neat, but I'm skeptical that it will work out of the box here: if you apply NBE to a standard

Re: [Caml-list] Weird GC behaviour

2011-09-28 Thread Gabriel Scherer
On Wed, Sep 28, 2011 at 1:53 PM, Thomas Fischbacher t.fischbac...@soton.ac.uk wrote: How come (Ftag funny) is regarded as constant while (Rtag (ref funny)) is not? After all, strings are mutable in OCaml, so there really is not that much of a conceptual difference between a string and a string

Re: [Caml-list] Dependent types ?

2011-09-26 Thread Gabriel Scherer
Phantom types could be a solution but we must declare a new type for each possible size, which is cumbersome / annoying. If you define the type system yourself, you can easily add a family of type constants `sizen` (with `n` an integer literal) to the default environment of the type checker.

Re: [Caml-list] Odd failure to infer types

2011-09-18 Thread Gabriel Scherer
On Sat, Sep 17, 2011 at 2:08 PM, Goswin von Brederlow goswin-...@web.de wrote: I think you are missing the point. I totaly get why it must be '_a instead if 'a. My question is why it doesn't infer the full type from the call to the print function. You're correct, I was missing your point. You

Re: [Caml-list] [Ann] Zarith

2011-08-18 Thread Gabriel Scherer
On Thu, Aug 18, 2011 at 10:02 AM, ri...@happyleptic.org wrote: Is there anything special in 3.12.1 to help library authors define specialized comparison operators ? Yes, from the 3.12.1 changelog: - Added new operation 'compare_ext' to custom blocks, called when comparing a custom block

Re: [Caml-list] Type generalization problem

2011-08-14 Thread Gabriel Scherer
You have hit the value restriction: http://caml.inria.fr/resources/doc/faq/core.en.html#eta-expansion # let g = (fun x - x) (fun x - x);; val g : '_a - '_a = fun # let g x = (fun x - x) (fun x - x) x;; val g : 'a - 'a = fun Polymorphism annotation ( : 'a . 'a - 'a ) have no use here, as you

Re: [Caml-list] filename and line number.

2011-08-03 Thread Gabriel Scherer
, but I would like to avoid cluttering the code with __LOCATION__ everywhere. Regards Anders Fugmann On 08/02/2011 11:21 PM, Martin Jambon wrote: On 08/02/11 05:45, Gabriel Scherer wrote: Finally, Martin Jambon also has its own cppo tools mimicking cpp, which I suppose doesn't rely

Re: [Caml-list] filename and line number.

2011-08-03 Thread Gabriel Scherer
I called ocamldoc by hand, the signatures I was interested in are actually all contained in camlp4/Camlp4/Sig.ml so there is not much to do. On Wed, Aug 3, 2011 at 9:57 PM, Till Varoquaux t...@pps.jussieu.fr wrote: On Tue, Aug 2, 2011 at 8:45 AM, Gabriel Scherer gabriel.sche...@gmail.com wrote

Re: [Caml-list] Linear Scan Register Allocator for ocamlopt/ocamlnat

2011-08-01 Thread Gabriel Scherer
This work is meant to make a compromise between generated code quality and compilation speed to have good performances in rapid prototyping/development scenario. Do you have more precise measurements on - the relative costs of the successive transformations during native compilation (including