* camlp4 unbound value
@ 2010-02-08 11:46 Guillaume Yziquel
2010-02-08 17:04 ` [Caml-list] " blue storm
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Yziquel @ 2010-02-08 11:46 UTC (permalink / raw)
To: OCaml List
Hi. This is for camlp4 gurus:
I've been using a modified version of Mauricio Fernandez' relational
algebra camlp4 extension for postgresql. (I'm trying to adapt it to
another database system, so I've functorised a bit of the original code).
You can find the modified code and a Debian package at:
http://yziquel.homelinux.org/debian/pool/main/o/ocaml-relational/
http://yziquel.homelinux.org/gitweb?p=ocaml-relational.git;a=summary
My question is the following: Relational.Conv_Postgresql.encode_int is
properly defined, and available from the toplevel, and yet considered
unbound in the camlp4-generated code.
How can this be?
> yziquel@seldon:~$ ocaml
> Objective Caml version 3.11.1
>
> # #use "topfind";;
> - : unit = ()
> Findlib has been successfully loaded. Additional directives:
> #require "package";; to load a package
> #list;; to list the available packages
> #camlp4o;; to load camlp4 (standard syntax)
> #camlp4r;; to load camlp4 (revised syntax)
> #predicates "p,q,...";; to set these predicates
> Topfind.reset();; to force that packages will be reloaded
> #thread;; to enable threads
>
> - : unit = ()
> # #thread;;
> /usr/lib/ocaml/threads: added to search path
> /usr/lib/ocaml/unix.cma: loaded
> /usr/lib/ocaml/threads/threads.cma: loaded
> # #camlp4o;;
> /usr/lib/ocaml/dynlink.cma: loaded
> /usr/lib/ocaml/camlp4: added to search path
> /usr/lib/ocaml/camlp4/camlp4o.cma: loaded
> Camlp4 Parsing version 3.11.1
>
> # #require "relational.postgresql";;
> /usr/lib/ocaml/pcre: added to search path
> /usr/lib/ocaml/pcre/pcre.cma: loaded
> /usr/lib/ocaml/netsys: added to search path
> /usr/lib/ocaml/netsys/netsys.cma: loaded
> /usr/lib/ocaml/netstring: added to search path
> /usr/lib/ocaml/netstring/netstring.cma: loaded
> /usr/lib/ocaml/netstring/netstring_mt.cmo: loaded
> /usr/lib/ocaml/netstring/netstring_top.cmo: loaded
> /usr/lib/ocaml/netstring/netaccel.cma: loaded
> /usr/lib/ocaml/netstring/netaccel_link.cmo: loaded
> /usr/lib/ocaml/relational: added to search path
> /usr/lib/ocaml/relational/relational.cma: loaded
> /usr/lib/ocaml/postgresql: added to search path
> /usr/lib/ocaml/postgresql/postgresql.cma: loaded
> /usr/lib/ocaml/relational/pa_relational.cmo: loaded
> /usr/lib/ocaml/relational/pa_relational_postgresql.cmo: loaded
> # TABLE user users COLUMN id SERIAL AUTO PRIMARY KEY END;;
> Error: Unbound value Relational.Conv_Postgresql.encode_int
> # module X = Relational.Conv_Postgresql;;
> module X :
> sig
> val encode_string : string -> string
> val decode_string : string -> string
> val decode_bool : string -> bool
> val encode_bool : bool -> string
> val encode_int : int -> string
> val decode_int : string -> int
> val encode_float : float -> string
> val decode_float : string -> float
> val encode_nullable : ('a -> string) -> 'a option -> string
> val decode_timestamp : string -> float
> val decode_timestampz : string -> float
> val encode_timestamp : float -> string
> val encode_timestampz : float -> string
> val decode_time : string -> float
> val decode_timez : string -> float
> val encode_time : float -> string
> val encode_timez : float -> string
> val decode_date : string -> Relational.Types.date
> val encode_date : Relational.Types.date -> string
> end
> # Relational.Conv_Postgresql.encode_int;;
> - : int -> string = <fun>
> #
--
Guillaume Yziquel
http://yziquel.homelinux.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] camlp4 unbound value
2010-02-08 11:46 camlp4 unbound value Guillaume Yziquel
@ 2010-02-08 17:04 ` blue storm
0 siblings, 0 replies; 2+ messages in thread
From: blue storm @ 2010-02-08 17:04 UTC (permalink / raw)
To: guillaume.yziquel; +Cc: OCaml List
[-- Attachment #1: Type: text/plain, Size: 4442 bytes --]
The problem I've seen when testing your code is slightly different
from the one you reported : Camlp4 choke on the "Relational.Conv_..."
string as containing different identifiers. The problem is that "A.B"
is not a legal uid, so you can't use it in a $uid:...$ antiquotation.
I've fixed this by using an Ast.ident instead of a string for the
type_conv value of the DB module. Hand-made diff attached.
On 2/8/10, Guillaume Yziquel <guillaume.yziquel@citycable.ch> wrote:
> Hi. This is for camlp4 gurus:
>
> I've been using a modified version of Mauricio Fernandez' relational
> algebra camlp4 extension for postgresql. (I'm trying to adapt it to
> another database system, so I've functorised a bit of the original code).
>
> You can find the modified code and a Debian package at:
>
> http://yziquel.homelinux.org/debian/pool/main/o/ocaml-relational/
> http://yziquel.homelinux.org/gitweb?p=ocaml-relational.git;a=summary
>
> My question is the following: Relational.Conv_Postgresql.encode_int is
> properly defined, and available from the toplevel, and yet considered
> unbound in the camlp4-generated code.
>
> How can this be?
>
>
>> yziquel@seldon:~$ ocaml
>> Objective Caml version 3.11.1
>>
>> # #use "topfind";;
>> - : unit = ()
>> Findlib has been successfully loaded. Additional directives:
>> #require "package";; to load a package
>> #list;; to list the available packages
>> #camlp4o;; to load camlp4 (standard syntax)
>> #camlp4r;; to load camlp4 (revised syntax)
>> #predicates "p,q,...";; to set these predicates
>> Topfind.reset();; to force that packages will be reloaded
>> #thread;; to enable threads
>>
>> - : unit = ()
>> # #thread;;
>> /usr/lib/ocaml/threads: added to search path
>> /usr/lib/ocaml/unix.cma: loaded
>> /usr/lib/ocaml/threads/threads.cma: loaded
>> # #camlp4o;;
>> /usr/lib/ocaml/dynlink.cma: loaded
>> /usr/lib/ocaml/camlp4: added to search path
>> /usr/lib/ocaml/camlp4/camlp4o.cma: loaded
>> Camlp4 Parsing version 3.11.1
>>
>> # #require "relational.postgresql";;
>> /usr/lib/ocaml/pcre: added to search path
>> /usr/lib/ocaml/pcre/pcre.cma: loaded
>> /usr/lib/ocaml/netsys: added to search path
>> /usr/lib/ocaml/netsys/netsys.cma: loaded
>> /usr/lib/ocaml/netstring: added to search path
>> /usr/lib/ocaml/netstring/netstring.cma: loaded
>> /usr/lib/ocaml/netstring/netstring_mt.cmo: loaded
>> /usr/lib/ocaml/netstring/netstring_top.cmo: loaded
>> /usr/lib/ocaml/netstring/netaccel.cma: loaded
>> /usr/lib/ocaml/netstring/netaccel_link.cmo: loaded
>> /usr/lib/ocaml/relational: added to search path
>> /usr/lib/ocaml/relational/relational.cma: loaded
>> /usr/lib/ocaml/postgresql: added to search path
>> /usr/lib/ocaml/postgresql/postgresql.cma: loaded
>> /usr/lib/ocaml/relational/pa_relational.cmo: loaded
>> /usr/lib/ocaml/relational/pa_relational_postgresql.cmo: loaded
>> # TABLE user users COLUMN id SERIAL AUTO PRIMARY KEY END;;
>> Error: Unbound value Relational.Conv_Postgresql.encode_int
>> # module X = Relational.Conv_Postgresql;;
>> module X :
>> sig
>> val encode_string : string -> string
>> val decode_string : string -> string
>> val decode_bool : string -> bool
>> val encode_bool : bool -> string
>> val encode_int : int -> string
>> val decode_int : string -> int
>> val encode_float : float -> string
>> val decode_float : string -> float
>> val encode_nullable : ('a -> string) -> 'a option -> string
>> val decode_timestamp : string -> float
>> val decode_timestampz : string -> float
>> val encode_timestamp : float -> string
>> val encode_timestampz : float -> string
>> val decode_time : string -> float
>> val decode_timez : string -> float
>> val encode_time : float -> string
>> val encode_timez : float -> string
>> val decode_date : string -> Relational.Types.date
>> val encode_date : Relational.Types.date -> string
>> end
>> # Relational.Conv_Postgresql.encode_int;;
>> - : int -> string = <fun>
>> #
>
> --
> Guillaume Yziquel
> http://yziquel.homelinux.org/
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
[-- Attachment #2: typeconv_module.diff --]
[-- Type: application/octet-stream, Size: 2754 bytes --]
Les sous-répertoires ocaml-relational-0.1/debian et ocaml-relational-0.1-new/debian sont identiques.
Les fichiers binaires ocaml-relational-0.1/.omakedb et ocaml-relational-0.1-new/.omakedb sont différents.
diff -u ocaml-relational-0.1/.omakedb.lock ocaml-relational-0.1-new/.omakedb.lock
--- ocaml-relational-0.1/.omakedb.lock 2010-02-08 12:51:31.000000000 +0100
+++ ocaml-relational-0.1-new/.omakedb.lock 2010-02-08 18:01:23.000000000 +0100
@@ -1 +1 @@
-*** omake: the project was last locked by seldon:14968.
+*** omake: the project was last locked by localhost:2447.
diff -u ocaml-relational-0.1/pa_relational.ml ocaml-relational-0.1-new/pa_relational.ml
--- ocaml-relational-0.1/pa_relational.ml 2010-02-08 12:51:32.000000000 +0100
+++ ocaml-relational-0.1-new/pa_relational.ml 2010-02-08 17:58:42.000000000 +0100
@@ -116,7 +116,7 @@
end
module type DB = sig
- val typeconv_module : string
+ val typeconv_module : Loc.t -> Ast.ident
end
module Codegenbase (DB : DB) : CODEGENBASE =
@@ -374,7 +374,7 @@
Some s -> <:expr< $lid:prefix ^ lowercase_to_string s$ >>
| None ->
let f = prefix ^ column_conv_typename t in
- <:expr< $id: <:ident< $uid:DB.typeconv_module$.$lid:f$ >> $ >>
+ <:expr< $id: <:ident< $DB.typeconv_module _loc$.$lid:f$ >> $ >>
(*<:expr< Relational.Typeconv.Postgresql.$lid:f$ >>*)
let col_nullable t = t.col_type.col_nullable
@@ -1055,4 +1055,4 @@
Camlp4.Options.add "--unsafe-relations"
(Arg.Unit (fun () -> use_type_constraint_funcs := false))
"Do not type-check relational algebra expressions."
-end
\ Pas de fin de ligne à la fin du fichier.
+end
diff -u ocaml-relational-0.1/pa_relational_monetdb5.ml ocaml-relational-0.1-new/pa_relational_monetdb5.ml
--- ocaml-relational-0.1/pa_relational_monetdb5.ml 2010-02-08 12:51:32.000000000 +0100
+++ ocaml-relational-0.1-new/pa_relational_monetdb5.ml 2010-02-08 17:59:50.000000000 +0100
@@ -5,9 +5,7 @@
struct
module DB = struct
-
- let typeconv_module = "Relational.Conv_MonetDB5"
-
+ let typeconv_module _loc = <:ident< Relational.Conv_MonetDB5 >>
end
include Codegenbase(DB)
diff -u ocaml-relational-0.1/pa_relational_postgresql.ml ocaml-relational-0.1-new/pa_relational_postgresql.ml
--- ocaml-relational-0.1/pa_relational_postgresql.ml 2010-02-08 12:51:32.000000000 +0100
+++ ocaml-relational-0.1-new/pa_relational_postgresql.ml 2010-02-08 17:58:55.000000000 +0100
@@ -5,9 +5,7 @@
struct
module DB = struct
-
- let typeconv_module = "Relational.Conv_Postgresql"
-
+ let typeconv_module _loc = <:ident< Relational.Conv_Postgresql >>
end
include Codegenbase(DB)
Les sous-répertoires ocaml-relational-0.1/test et ocaml-relational-0.1-new/test sont identiques.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-08 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08 11:46 camlp4 unbound value Guillaume Yziquel
2010-02-08 17:04 ` [Caml-list] " blue storm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox