caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rich@annexia.org>
To: Florian Angeletti <octa@polychoron.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Returning printf from a function
Date: Thu, 23 Aug 2018 11:23:08 +0100	[thread overview]
Message-ID: <20180823102308.5mnfm7x3p26lgrhp@annexia.org> (raw)
In-Reply-To: <81f925d8-a5e0-2c6b-b2c7-a752e2db4135@polychoron.fr>

On Thu, Aug 23, 2018 at 12:08:10PM +0200, Florian Angeletti wrote:
> A solution that works in this specific example and does not require to
> rewire the logic is
> to return the printing function inside a record with the right universal
> quantification:
> 
> ...
> 
> type debug = {fn: 'a. ('a, unit, string, unit) format4 -> 'a }[@@unboxed];;
> 
> let udebug = {fn=debug}
> 
> let give_fn () = Some udebug
> 
> ...
> 
>   | Some {fn} ->
>     fn "fn";
>     fn "fn param: %s" param

Thanks, that does indeed work.

Rich.

-- 
Richard Jones

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

      reply	other threads:[~2018-08-23 10:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23  9:15 Richard W.M. Jones
2018-08-23  9:28 ` Florian Angeletti
2018-08-23  9:48   ` Richard W.M. Jones
2018-08-23 10:08     ` Florian Angeletti
2018-08-23 10:23       ` Richard W.M. Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180823102308.5mnfm7x3p26lgrhp@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    --cc=octa@polychoron.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).