caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] pgocaml and lwt
@ 2012-09-30 22:04 Pierre Chopin
  2012-09-30 22:31 ` Sebastien Mondet
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Chopin @ 2012-09-30 22:04 UTC (permalink / raw)
  To: caml-list

Hi,
I am trying to use pgocaml and lwt, but I have some error I can't understand:

(**********************************************)
(**********************************************)


module Thread =
struct
open Lwt
open Lwt_io
type 'a t = 'a Lwt.t
let (>>=) = (>>=)
let return = return
let fail = fail
type in_channel = input_channel
type out_channel = output_channel
let open_connection addr = open_connection ~buffer_size:2097152 addr
let output_char = write_char
let  output_binary_int =  write_int
let output_string  = write
let flush = flush
let input_char = read_char
let input_binary_int = read_int
let really_input =read_into_exactly
let close_in = close
end


module Lwt_db = PGOCaml_generic.Make(Thread)
open Lwt_db

open Lwt

let query_user dbh id =
PGSQL(dbh) "SELECT id,name,visited FROM user_db WHERE id=$id"

let _ =
    Lwt_main.run
        (connect ~database:"schat" ()>|=
            function dbh -> query_user dbh 1L)

(**********************************************)
(**********************************************)

when I try to compile :


$ ocamlfind ocamlc -thread -c -package lwt,pgocaml,pgocaml.syntax -syntax
camlp4o test.ml

File "test.ml", line 34, characters 30-33:
Error: This expression has type
         'a Lwt_db.t = 'a PGOCaml_generic.Make(Thread).t
       but an expression was expected of type
         (string, bool) Hashtbl.t PGOCaml.t




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

* Re: [Caml-list] pgocaml and lwt
  2012-09-30 22:04 [Caml-list] pgocaml and lwt Pierre Chopin
@ 2012-09-30 22:31 ` Sebastien Mondet
  2012-09-30 22:37   ` Pierre Chopin
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastien Mondet @ 2012-09-30 22:31 UTC (permalink / raw)
  To: Pierre Chopin; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2025 bytes --]

Hi

If I remember correctly, the syntax extension will use the module called
PGOCaml which is "in scope", so you need to hide the "preemtive threads"
one with yours:

module PGOCaml = PGOCaml_generic.Make(Thread)


Cheers
Seb


On Sun, Sep 30, 2012 at 6:04 PM, Pierre Chopin <pierre.chopin@u-psud.fr>wrote:

> Hi,
> I am trying to use pgocaml and lwt, but I have some error I can't
> understand:
>
> (**********************************************)
> (**********************************************)
>
>
> module Thread =
> struct
> open Lwt
> open Lwt_io
> type 'a t = 'a Lwt.t
> let (>>=) = (>>=)
> let return = return
> let fail = fail
> type in_channel = input_channel
> type out_channel = output_channel
> let open_connection addr = open_connection ~buffer_size:2097152 addr
> let output_char = write_char
> let  output_binary_int =  write_int
> let output_string  = write
> let flush = flush
> let input_char = read_char
> let input_binary_int = read_int
> let really_input =read_into_exactly
> let close_in = close
> end
>
>
> module Lwt_db = PGOCaml_generic.Make(Thread)
> open Lwt_db
>
> open Lwt
>
> let query_user dbh id =
> PGSQL(dbh) "SELECT id,name,visited FROM user_db WHERE id=$id"
>
> let _ =
>     Lwt_main.run
>         (connect ~database:"schat" ()>|=
>             function dbh -> query_user dbh 1L)
>
> (**********************************************)
> (**********************************************)
>
> when I try to compile :
>
>
> $ ocamlfind ocamlc -thread -c -package lwt,pgocaml,pgocaml.syntax -syntax
> camlp4o test.ml
>
> File "test.ml", line 34, characters 30-33:
> Error: This expression has type
>          'a Lwt_db.t = 'a PGOCaml_generic.Make(Thread).t
>        but an expression was expected of type
>          (string, bool) Hashtbl.t PGOCaml.t
>
>
>
>
> --
> 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
>

[-- Attachment #2: Type: text/html, Size: 3006 bytes --]

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

* Re: [Caml-list] pgocaml and lwt
  2012-09-30 22:31 ` Sebastien Mondet
@ 2012-09-30 22:37   ` Pierre Chopin
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Chopin @ 2012-09-30 22:37 UTC (permalink / raw)
  To: Sebastien Mondet; +Cc: Pierre Chopin, caml-list

It was indeed the problem.

Thanks !

Le Dim 30 septembre 2012 15:31, Sebastien Mondet a écrit :
> Hi
>
>
> If I remember correctly, the syntax extension will use the module called
> PGOCaml which is "in scope", so you need to hide the "preemtive threads"
> one with yours:
>
> module PGOCaml = PGOCaml_generic.Make(Thread)
>
>
> Cheers
> Seb
>
>
>
> On Sun, Sep 30, 2012 at 6:04 PM, Pierre Chopin
> <pierre.chopin@u-psud.fr>wrote:
>
>
>> Hi,
>> I am trying to use pgocaml and lwt, but I have some error I can't
>> understand:
>>
>>
>> (**********************************************)
>> (**********************************************)
>>
>>
>>
>> module Thread = struct open Lwt open Lwt_io type 'a t = 'a Lwt.t let
(>>=) =
>> (>>=)
>> let return = return let fail = fail type in_channel = input_channel type
>> out_channel = output_channel let open_connection addr = open_connection
>> ~buffer_size:2097152 addr
>> let output_char = write_char let  output_binary_int =  write_int let
>> output_string  = write let flush = flush let input_char = read_char let
>> input_binary_int = read_int let really_input =read_into_exactly let
>> close_in = close end
>>
>>
>> module Lwt_db = PGOCaml_generic.Make(Thread) open Lwt_db
>>
>> open Lwt
>>
>> let query_user dbh id = PGSQL(dbh) "SELECT id,name,visited FROM user_db
>> WHERE id=$id"
>>
>>
>> let _ = Lwt_main.run
>> (connect ~database:"schat" ()>|=
>> function dbh -> query_user dbh 1L)
>>
>> (**********************************************)
>> (**********************************************)
>>
>>
>> when I try to compile :
>>
>>
>> $ ocamlfind ocamlc -thread -c -package lwt,pgocaml,pgocaml.syntax
>> -syntax
>> camlp4o test.ml
>>
>> File "test.ml", line 34, characters 30-33:
>> Error: This expression has type
>> 'a Lwt_db.t = 'a PGOCaml_generic.Make(Thread).t
>> but an expression was expected of type (string, bool) Hashtbl.t PGOCaml.t
>>
>>
>>
>>
>>
>> --
>> 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
>>
>>
>
> --
> 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



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

end of thread, other threads:[~2012-09-30 22:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-30 22:04 [Caml-list] pgocaml and lwt Pierre Chopin
2012-09-30 22:31 ` Sebastien Mondet
2012-09-30 22:37   ` Pierre Chopin

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