caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: msk@post.tepkom.ru
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] format types
Date: Thu, 27 Sep 2001 09:35:01 +0900	[thread overview]
Message-ID: <20010927093501F.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <01092512594301.08201@kouzdra.glokaya>

> why 
> 
> let _ = List.map printf (["abc\n"; "def\n"]:('a,'b,'c) format list)
> 
> work properly, but:
> 
>  let _ = List.map printf ["abc\n"; "def\n"]
> 
> doesn't compiled with message
> 
>  This expression has type ('a, out_channel, unit) format -> 'a
>  but is here used with type string -> 'b
> 
> I know, O'Caml format type is a hack, but I can't undertand difference 
> between thees two expressions for the type inference algorighm.

You have the answer: this is a hack, and there are no guarantees
anything will type (or have the expected side-effects) if you do not
follow the documentation.

If you understand how the hack works, then you can write the
following (which does not seem very useful):

# let map_printf l = List.map Printf.printf l;;
val map_printf : ('a, out_channel, unit) format list -> 'a list = <fun>
# map_printf ["abc"; "def"];;
abcdef- : unit list = [(); ()]

        Jacques Garrigue
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-09-27  0:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-24 23:40 [Caml-list] Initial port of ocaml for mingw (long) art
2001-09-25  8:59 ` [Caml-list] format types Anton Moscal
2001-09-27  0:35   ` Jacques Garrigue [this message]
2001-10-17 19:07 ` [Caml-list] Ocaml 3.03 alpha MinGW port Dmitry Bely
2001-10-22  1:46   ` Masakazu Fukuzawa
2001-10-22 14:56     ` Dmitry Bely
2001-10-22 16:18       ` Masakazu Fukuzawa

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=20010927093501F.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=msk@post.tepkom.ru \
    /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).