English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Initial port of ocaml for mingw (long)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-09-27 (00:35)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] format types
> 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