From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 17517BBAF for ; Sun, 6 Jul 2008 17:33:38 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsEFAE+CcEjRVZK3Y2dsb2JhbACSGTkaBB4DlVODbg X-IronPort-AV: E=Sophos;i="4.30,311,1212357600"; d="scan'208";a="27066794" Received: from wa-out-1112.google.com ([209.85.146.183]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Jul 2008 17:33:37 +0200 Received: by wa-out-1112.google.com with SMTP id j4so1096712wah.3 for ; Sun, 06 Jul 2008 08:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=ftFwWE8oTxKJ3GQuBaLnqT2YY2T7Jw6TbNNb76R/SB0=; b=iHmkvcXv6M6qBO7Nwb8cFndRugPauDRtmu4SRYyt/H3hRMVUpYVO6O8GB6/AuzbJvl kjwQXl+/iq1X9YEPIE1cC+ypKxC66TTlQUyrkN3ysGlGoPJ/wBE0jiVJpH9B3p38RbGP TCgU+Y0DoYm2haZ5ll3P9A7pWy1WexLvAZu8E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=CV6Ddy+xhOIe4dVS5U3Acg3i+Y8VKUu5hkMbeSnveEd8aJxUpiWYdWR8jQTSSeE/ZW De7GrXQZlZcSt6ZiiY3JpKEbQJaY6OxUtzygC33h1TTKVSN2rOKPSkPMRoR5NS+q/KyC zYkJvRLi06cz5PmG/MAm9KPoX48KMhtnxNEwc= Received: by 10.114.15.1 with SMTP id 1mr5335866wao.184.1215358416098; Sun, 06 Jul 2008 08:33:36 -0700 (PDT) Received: by 10.115.47.20 with HTTP; Sun, 6 Jul 2008 08:33:35 -0700 (PDT) Message-ID: <3be64c030807060833y155230a2gaeaf0e531827ddb3@mail.gmail.com> Date: Sun, 6 Jul 2008 11:33:35 -0400 From: "Antony Courtney" To: caml-list@yquem.inria.fr Subject: Newbie question: OCaml equivalent of Haskell's show? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Spam: no; 0.00; ocaml:01 haskell's:01 haskell:01 ocaml:01 runtime:01 recursive:01 haskell:01 programmatic:01 toplevel:01 -antony:01 polymorphic:01 faq:01 short:01 arbitrary:02 newbie:02 I'm an experienced Haskell hacker trying OCaml for the first time. One thing I am desperately searching for but have been unable to find is some direct runtime access to the string representation of arbitrary OCaml values. I have written a little option pricer that constructs a float option array array in a function. I've got a little buglet in my function so I'd like to print the intermediate states of this value from inside the function. How do I do that, short of writing my own recursive pretty printer / formatter? An OCaml form of the Haskell Show type class would be great, but a hack to provide programmatic access to the polymorphic pretty printer that obviously already exists in the OCaml toplevel would be fine. I've scoured the standard library docs, manual, tutorials and a few books, looked at the FAQ and am amazed that I haven't found the answer to this. I am hopefully just missing something obvious; would be grateful if someone could point me towards the answer! Apologies if this belongs on ocaml-beginners. Thanks, -Antony