It's a beginner question, but the yahoo beginner's group is very well
protected behind various entries barriers so I'll try my luck here.
I want a function that takes a vector (
http://docs.camlcity.org/docs/godipkg/3.10/godi-lacaml/doc/godi-lacaml/html/Vec4_S.html
) as input and outputs a string (the aim is passing this function as
an argument to assert_equal in OUnit and maybe finding my bug).
So, as a naive person, I tried to use sprintf "%a" and the pp_fvec
( http://docs.camlcity.org/docs/godipkg/3.10/godi-lacaml/doc/godi-lacaml/html/Io.html#VALpp_fvec
) formatter. But I've got a strange type error that I honestly can't
interpret without help.
here is the whole file :
open Format
open Lacaml.Impl.D
open Lacaml.Io
let _ = sprintf "%a" pp_fvec (Vec.of_array [| 30.; 15.; - 6. |])
here is the error message :
/usr/local/bin/ocamlc.opt -c -I /usr/local/lib/ocaml/site-lib/lacaml/ -
I /usr/local/lib/ocaml/site-lib/oUnit/ -dtypes -o test_sprintf.cmo
test_sprintf.ml
+ /usr/local/bin/ocamlc.opt -c -I /usr/local/lib/ocaml/site-lib/
lacaml/ -I /usr/local/lib/ocaml/site-lib/oUnit/ -dtypes -o
test_sprintf.cmo test_sprintf.ml
File "test_sprintf.ml", line 4, characters 21-28:
This expression has type
(float, 'a) Lacaml.Io.pp_vec =
Format.formatter ->
(float, 'a, Bigarray.fortran_layout) Bigarray.Array1.t -> unit
but is here used with type unit -> 'b -> string
Command exited with code 2.
Moreover, when trying to google about sprintf, I found that it's
basically hacked int the compiler (with p4 I suppose) but I didn't
find any specifics about HOW it is hacked and why it's type doesn't
returns string (I found that the return type is encoded has an
argument type, but it doesn't demystifie the thing or helps me
correcting my bug).
If anybody can help me or point me to a relevant documentation, I
would be very pleased.
Thank you,
Nicolas.