List Info

Thread: "ocaml_beginners"::[] ocamlopt cannot infer type, complete short example attached?




"ocaml_beginners"::[] ocamlopt cannot infer type, complete short example attached?
country flaguser name
United States
2008-03-06 08:57:48

Can you identify the problem here?
Why are the type constraints not working?

1. $ ocamlopt test_type.mli test.ml

File "test.ml", line 4, characters 0-186:
Signature mismatch:
Modules do not match:
sig type t = P.t val init : 'a -> 'b -> 'a * 'b end
is not included in
Test_type.BaseType
Values do not match:
val init : 'a -> 'b -> 'a * 'b
is not included in
val init : string -> int -> t

2. init in MakeBase() commented out and second version of init
uncommented (i.e. explicit types are given for everything)
$ ocamlopt test_type.mli test.ml
File "test.ml", line 9, characters 43-54:
This expression has type string * int but is here used with type t = P.t

----- test_type.mli attached here ---------
module type ParamType =
sig
type t

val is_true: t -> bool
end

module type BaseType =
sig
type t

val init: string -> int -> t
end

module MakeBase(P : ParamType) : BaseType with type t = P.t
----- end of test_type.mli ---------------

------- test.ml begins -------------
open Test_type

module MakeBase(P : ParamType) : BaseType =
struct
type t = P.t

let init text len = (text, len)
(* let init (text: string) (len:int) : t = (text, len) *)

(* the second definition with explicit types fails also *)
end

module Param : ParamType =
struct
type t = string * int

let is_true arg = let (_, len) = arg in len > 0
end

module MyModule = MakeBase(Param)

let _ =
let (result, len) = MyModule.init "text" 10 in
Printf.printf "%s %dn" result len
------- end of test.ml --------

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] MySQL stored procedures?
country flaguser name
United States
2008-03-28 10:42:52

Anyone had any success calling a stored procedure with Ocaml-MySQL? I haven't
been able to figure out how to alter the connection string to send
CLIENT_MULTI_STATEMENTS and CLIENT_MULTI_RESULTS.

Thanks,
-Mark

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )