[Caml-list] Linking to C libraries when calling camlp4

2010-01-29 Thread Joseph Young
Hi, How do you link to external C libraries when calling camlp4? When calling ocamlc, we can use the -custom and -cclib flags in order to statically link a library. However, the camlp4 executable seems to ignore these flags when called. As an example, given the files: - $

Re: [Caml-list] camlp4

2010-02-07 Thread Joseph Young
On Sat, 6 Feb 2010, Andy Ray wrote: Hi, My project would really benefit from some simple camlp4 syntax extensions, however, I am put off by the lack of a reference manual for it. At the moment I am tempted to go for camlp5 instead - not least because I was able to work through it's manual and

[Caml-list] Two Different Exception Behaviors in camlp4 on the toplevel

2010-05-23 Thread Joseph Young
Hi, At the moment, I'm receiving two different exception behaviors in camlp4 on the toplevel and I would like to unify them. As some background, I would like to implement a small DSL where I insert OCaml code using quotations. This causes some difficulty with type checking since it may or m

Re: [Caml-list] Two Different Exception Behaviors in camlp4 on the toplevel

2010-05-25 Thread Joseph Young
The type checking using phantom types worked great. Thanks. In case it helps anyone else, I'm attaching complete working code below. Joe $ cat calc.ml open Camlp4.PreCast;; module CamlSyntax= Camlp4OCamlParser.Make( Camlp4OCamlRevisedParser.Make(

[Caml-list] Conditionals based on phantom types

2010-08-02 Thread Joseph Young
Hi, Is there any way to write a conditional based on the type information of a value? Specifically, if we use phantom types to write a module such as module Units : sig type 'a t val to_feet : float -> [`Feet ] t val to_meters : float -> [`Meters] t val add : 'a t -> 'a t ->

Re: [Caml-list] Conditionals based on phantom types

2010-08-02 Thread Joseph Young
I appreciate the reply and the suggestions. After looking over your responses, could everything be simplified by removing the phantom types? In other words, is there a draw back to using the definition: type units=[`Feet | `Meters];; let to_feet x : [`Feet]*float=`Feet,x;; let to_meters x :

Re: [Caml-list] Conditionals based on phantom types

2010-08-02 Thread Joseph Young
et add (u,x) (_,y) = u,x +. y;; let print (u,x)=Printf.printf "%f (%s)" x (unit_to_string u);; end Then, expressions as the one above can not be written. Joe On Tue, 3 Aug 2010, Joseph Young wrote: I appreciate the reply and the suggestions. After looking over your responses, could

Re: [Caml-list] Conditionals based on phantom types

2010-08-03 Thread Joseph Young
On Tue, 3 Aug 2010, bluestorm wrote: On Tue, Aug 3, 2010 at 8:15 AM, Joseph Young wrote: module Units : sig    type t    val to_feet : float -> [`Feet]*t    val to_meters : float -> [`Meters]*t [..] end With this type, the value representation of units is not abstract anymore (and