caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Florian Angeletti <octa@polychoron.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Returning printf from a function
Date: Thu, 23 Aug 2018 12:08:10 +0200	[thread overview]
Message-ID: <81f925d8-a5e0-2c6b-b2c7-a752e2db4135@polychoron.fr> (raw)
In-Reply-To: <20180823094826.xhc253lxxgt5la7a@annexia.org>

[-- Attachment #1: Type: text/plain, Size: 609 bytes --]

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



-- 
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

[-- Attachment #2: Type: text/html, Size: 1163 bytes --]

  reply	other threads:[~2018-08-23 10:08 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 [this message]
2018-08-23 10:23       ` Richard W.M. Jones

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=81f925d8-a5e0-2c6b-b2c7-a752e2db4135@polychoron.fr \
    --to=octa@polychoron.fr \
    --cc=caml-list@inria.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).