From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTP id 7666F5D4 for ; Tue, 4 Sep 2018 08:14:45 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.53,328,1531778400"; d="scan'208";a="344783562" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 04 Sep 2018 10:14:43 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 19F95824DE; Tue, 4 Sep 2018 10:14:43 +0200 (CEST) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 56D60824B2 for ; Tue, 4 Sep 2018 10:14:34 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=asmadeus77@gmail.com; spf=Pass smtp.mailfrom=asmadeus@notk.org; spf=None smtp.helo=postmaster@nautica.notk.org IronPort-PHdr: =?us-ascii?q?9a23=3AChrBpxBO1s1p1VP01YOJUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSPv8rsbcNUDSrc9gkEXOFd2Cra4c1KyO6+jJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6?= =?us-ascii?q?JvjvGo7Vks+7y/2+94fcbglUhjexe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfO?= =?us-ascii?q?pWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnM?= =?us-ascii?q?VhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs5Qiqp4bt1RxD0iS?= =?us-ascii?q?cHLz85/3/Risxsl6JQvRatqwViz4LIfI2ZMfxzdb7fc9wHX2pMRshfWSxfDI2h?= =?us-ascii?q?bIUPAeUOMvpFoIb/qVQDtge+CRW2Ce/z1jNFnH370Ksn2OohCwHG2wkgEsoAvn?= =?us-ascii?q?TTqdX1NaESUeGszKnV0zrIcvRY1i3n6IjUcxAhp++DXa5tesfW00YvDAbFgU+N?= =?us-ascii?q?poP7IjOVzeYAvmqA4upvUOKgkW8nqwVrrjezwccsj5DEi4QIwV7H7SV02II4Kc?= =?us-ascii?q?CiREJmf9KoDYFcuiOHO4dsX88vTGNltSAnwbMco5G7ZjIFyJE/yh7fdfOHd4+I?= =?us-ascii?q?7wrlVOmLPDd4mHNld66liBqo90igzfH8Vsqu3FZNtCpFncHAtnEL1xPN9siKUv?= =?us-ascii?q?9w8lq71TqSyQzf9/tILEIpmabBNpIszbw9moIWsUvZHy/2nEv2jLWRdkUh4uWn?= =?us-ascii?q?8f/nYrD8qZCBKYB0lxr+P78omsy4HeQ4MRICX2+B+eSzzLHj51H2QK1Wjv0qla?= =?us-ascii?q?nUqIzVKt4epq69GgNV1ocj6w2jDzq9y9QZnXwHLEpfdx6djojpPUvOIPHiAvul?= =?us-ascii?q?jVSsimQj+/eTEKfoBJ7KL2OLuprbUJBSxnQUnAA+191Z6J9OTL8bKfT4XU7q8o?= =?us-ascii?q?OCUjc8dQ+l3v3nFZBgkIoVH2CXVPy3KqTX5HOP4+MpIvCRaccwsSzhKv4o+7a6?= =?us-ascii?q?hGQ8kFMQYLL2grMYbXm5GrJtJEDPMimkucsIDWpf5ll2d+ftklDXFGcLPy/jDZ?= =?us-ascii?q?J53SkyDcedNamGQ4mshLKb2yLiRs9QYXxFTFeWHiWxLtnWa7I3cCuXZ/RZvHkc?= =?us-ascii?q?T7H4Et0u0BivsEnxzL81drOJqB1djorq0Z1O38OWlRw28mUkXcKUzn2MRGgymG?= =?us-ascii?q?QURHkxxq8t+UE=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0D9BABjPo5b/5NHeVtaDgwBAQEBAQIBA?= =?us-ascii?q?QEBCAEBAQGDTlqBCoQalEFPAQEBBoFJiDQbAgVlg1lPiDaCBQUmAYgaGQcBBDI?= =?us-ascii?q?WAQIBAQIBAQEBAWwogjUkAYJeBiMENR0QCxoCBRMOAgIPBQ8JMYUdAQsRoyV7F?= =?us-ascii?q?gUBF4ZZChmBCoF3gQuJTYEQgQeDdi6HfzGCBCICgScBAZosAQYCAYFBBI4pIgm?= =?us-ascii?q?BN4czhWaTZYFIAy6BVU0jUIEegU+QGDw9gSsBAYxXAQE?= X-IPAS-Result: =?us-ascii?q?A0D9BABjPo5b/5NHeVtaDgwBAQEBAQIBAQEBCAEBAQGDTlq?= =?us-ascii?q?BCoQalEFPAQEBBoFJiDQbAgVlg1lPiDaCBQUmAYgaGQcBBDIWAQIBAQIBAQEBA?= =?us-ascii?q?WwogjUkAYJeBiMENR0QCxoCBRMOAgIPBQ8JMYUdAQsRoyV7FgUBF4ZZChmBCoF?= =?us-ascii?q?3gQuJTYEQgQeDdi6HfzGCBCICgScBAZosAQYCAYFBBI4pIgmBN4czhWaTZYFIA?= =?us-ascii?q?y6BVU0jUIEegU+QGDw9gSsBAYxXAQE?= X-IronPort-AV: E=Sophos;i="5.53,328,1531778400"; d="scan'208";a="277625275" Received: from nautica.notk.org ([91.121.71.147]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2018 10:14:33 +0200 Received: by nautica.notk.org (Postfix, from userid 1001) id 3FBF9C009; Tue, 4 Sep 2018 10:14:33 +0200 (CEST) Date: Tue, 4 Sep 2018 10:14:18 +0200 From: Dominique Martinet To: Francois BERENGER Cc: caml-list@inria.fr Message-ID: <20180904081418.GA14131@nautica> References: <20180904062257.GA29189@nautica> <903e65e7-61b2-f18d-9c39-09757f1ca7f4@m.kyushu-u.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <903e65e7-61b2-f18d-9c39-09757f1ca7f4@m.kyushu-u.ac.jp> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [Caml-list] Strange online ocamldoc for Scanf Reply-To: Dominique Martinet X-Loop: caml-list@inria.fr X-Sequence: 17047 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Francois BERENGER wrote on Tue, Sep 04, 2018: > > ('a, 'b, 'c, 'd) scanner is itself a function taking two arguments, as > > defined a bit later in the page: > > > > type ('a, 'b, 'c, 'd) scanner = ('a, Scanning.in_channel, 'b, 'c, 'a -> 'd, 'd) format6 -> > > 'c > > Ok, my mistake. > > I have to admit that I don't understand such a (lengthy) type > definition, probably because I don't read such ones very often. Well, to be fair, it doesn't say "two arguments" here -- 'c happens to be a function itself... What's important is there is an arrow (->) in the type definition so a scanner is a function, and which can return any type 'c when given a format, so depending on what you give it you'll get something else. I think it's interesting to play with it in the toplevel: # open Scanf;; # Scanf.sscanf;; - : string -> ('a, 'b, 'c, 'd) Scanf.scanner = # let s = Scanf.sscanf "15" "%d";; val s : (int -> '_weak1) -> '_weak1 = # s (fun d -> "something");; - : string = "something" # s;; - : (int -> string) -> string = So when I first assigned 's' I got a function, which takes in argument a function expecting and int and returning "something" The '_weak1 here is like 'a except that it "solidifies" on first use, as you can see after calling 's' with a function once it will expect that all further use of 's' will be with a string-returning function Good luck, -- Dominique -- 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