caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dominique Martinet <asmadeus77@gmail.com>
To: Francois BERENGER <berenger.francois.724@m.kyushu-u.ac.jp>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Strange online ocamldoc for Scanf
Date: Tue, 4 Sep 2018 08:22:57 +0200	[thread overview]
Message-ID: <20180904062257.GA29189@nautica> (raw)
In-Reply-To: <b2749c8d-b4f6-42f8-f196-288150821c6d@m.kyushu-u.ac.jp>

Francois BERENGER wrote on Tue, Sep 04, 2018:
> It seems type signatures are truncated.
> 
> For example in:
> https://caml.inria.fr/pub/docs/manual-ocaml/libref/Scanf.html
> 
> val sscanf : string -> ('a, 'b, 'c, 'd) scanner
> 
> I would expect sscanf to take three arguments, not one.

The documentation is correct (and you also are correct that sscanf takes
three arguments, but...)

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


Basically, to use the example on the page with sscanf "x = 1" "%s = %i" f,
sscanf "x = 1" return a scanner to which you can apply a pattern and a
function - ultimately that is three arguments as you describe, but
thanks to currying after applying one argument you get anther function.

This is useful because basically you do not care if the scanner comes
from 'sscanf "x = 1"' or 'scanf' or 'bscanf some_channel' -- all three
are equivalent scanners


Cheers,
-- 
Dominique Martinet | Asmadeus
(what am I doing here?)

-- 
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-09-04  6:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04  6:05 Francois BERENGER
2018-09-04  6:22 ` Dominique Martinet [this message]
2018-09-04  7:45   ` Francois BERENGER
2018-09-04  8:14     ` Dominique Martinet

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=20180904062257.GA29189@nautica \
    --to=asmadeus77@gmail.com \
    --cc=berenger.francois.724@m.kyushu-u.ac.jp \
    --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).