Thanks Jérémie for doing this, it's a very useful feature.

I would like to fetch the git repository but it won't let me:

$ git clone 'http://www.dimino.org/git/ocaml-3.12.1-print.git'
Cloning into ocaml-3.12.1-print...
fatal: http://www.dimino.org/git/ocaml-3.12.1-print.git/info/refs not
found: did you run git update-server-info on the server?


Martin


On 12/07/2011 07:28 AM, Jérémie Dimino wrote:
> Hi,
> 
> I have made a patch for ocaml 3.12.1 which allow to have a generic
> printing function. The patch is available here:
> 
>   http://www.dimino.org/ocaml-3.12.1-generic-print.patch
> 
> Here is how to use it:
> 
>   external show : 'a -> string = "%show"
> 
>   let () = print_endline (show ([1; 2; 3], Some "foo"))
> 
> this will print:
> 
>   ([1; 2; 3], Some "foo")
> 
> It is also possible to define custom printers, for example:
> 
>   module StringMap : sig
>     include Map.S with type key = string
>     val string_of_t : ('a -> string) -> 'a t -> string
>   end = struct
>     include Map.Make(String)
>     let string_of_t (type a) string_of_a (m : a t) =
>       show (bindings m)
>   end
> 
>   let () = print_endline (show (StringMap.singleton "x" 1))
> 
> will print:
> 
>   [("x", 1)]
> 
> Of course it is limited to what the compiler knows, for example the
> following function will always returns "[<poly>; <poly>]":
> 
>   let f x = show [x; x]
> 
> But i think it is already very useful for debugging.
> 
> The git repo is here:
> 
>   http://www.dimino.org/gitweb/?p=ocaml-3.12.1-print.git;a=summary
> 
> Cheers,
> 


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to