caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Francois BERENGER <berenger.francois.724@m.kyushu-u.ac.jp>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Strange online ocamldoc for Scanf
Date: Tue, 4 Sep 2018 16:45:55 +0900	[thread overview]
Message-ID: <903e65e7-61b2-f18d-9c39-09757f1ca7f4@m.kyushu-u.ac.jp> (raw)
In-Reply-To: <20180904062257.GA29189@nautica>

On 09/04/2018 03:22 PM, Dominique Martinet wrote:
> 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

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.

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

-- 
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  7:47 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
2018-09-04  7:45   ` Francois BERENGER [this message]
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=903e65e7-61b2-f18d-9c39-09757f1ca7f4@m.kyushu-u.ac.jp \
    --to=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).