List Info

Thread: "ocaml_beginners"::[] Is there similar function print_any as F# in OCaml ?




"ocaml_beginners"::[] Is there similar function print_any as F# in OCaml ?
user name
2006-08-21 19:51:56
On Mon, 21 Aug 2006, LORENZO wrote:

> There is a print_any function of F# can output any type
of data on 
> console.
>
> Does OCaml have similar function to use?

This is difficult to do because OCaml doesn't provide
runtime type 
information. If you're using the toplevel, you can use
#install_printer to 
add formatters for custom types so that inspection at the
toplevel 
displays your data the way you want. If you need to print
your data to 
standard out, the closest I've seen is this:

http://merjis.com
/developers/dumper

As the page explains, this feature is now part of ExtLib.

-- 
.. Dave Benjamin - Software Developer - ramenlabs.com
.. AIM: ramenlabs / MSN: ramenlabshotmail.com


Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



"ocaml_beginners"::[] Is there similar function print_any as F# in OCaml ?
user name
2006-08-30 15:15:42
    Since I just want to know the built-in type of
    the parameter enter to a function, I tried

    #let testype x =
       if x <> 0 or x = 0 then
          Printf.printf "%d\n" x
       else if ( x <> 1. or x = 1. ) then
          Printf.printf "%f\n" x
        ;; 
    Characters 100-102:
        else if ( x <> 1. or x = 1. ) then
                       ^^
    This expression has type float but is here used with
type int

    Thus got above type inference error, it seemed kind of
    dumb thing I did to write a function to test input type,
    OCaml would already inference the type of expressions.

    Instead of my previous question, how should I get 
    the inference type of function input which OCaml
actually
    had inferenced ?



--- In ocaml_beginners@yahoogroups.com, Dave Benjamin
<ramen...> wrote:
>
> On Mon, 21 Aug 2006, LORENZO wrote:
> 
> > There is a print_any function of F# can output any
type of data on 
> > console.
> >
> > Does OCaml have similar function to use?
> 
> This is difficult to do because OCaml doesn't provide
runtime type 
> information. If you're using the toplevel, you can use
#install_printer to 
> add formatters for custom types so that inspection at
the toplevel 
> displays your data the way you want. If you need to
print your data to 
> standard out, the closest I've seen is this:
> http://merjis.com
/developers/dumper
> As the page explains, this feature is now part of
ExtLib.
> -- 
> .. Dave Benjamin - Software Developer - ramenlabs.com
> .. AIM: ramenlabs / MSN: ramenlabs...
>






Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



[1-2]

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