From: Diego Olivier Fernandez Pons <dofp.ocaml@gmail.com>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Puzzled by Scanf.Scanning.in_channel
Date: Mon, 4 Jun 2012 20:59:26 +0200 [thread overview]
Message-ID: <CAHqiZ-+mJuOrtE03rftvrodxU4pfCfndQToJEHS0LRHa6Xwb-w@mail.gmail.com> (raw)
Caml-List,
When I try to use Scanf.fscanf with an input channel created with
Scanf.Scanning.from_string the type checker complains
let s = Scanf.Scanning.from_string "3" in Scanf.fscanf s "%i" (fun x -> x);;
Characters 55-56:
Error: This expression has type Scanf.Scanning.in_channel
but an expression was expected of type in_channel
Which confuses me as from the manual I understood this should have worked.
val from_string : string -> in_channel
Scanning.from_string s returns a formatted input channel which
reads from the given string. Reading starts from the first character
in the string. The end-of-input condition is set when the end of the
string is reached.
Could anyone explain how is the proper way to generate a input channel
from a string ? Its for testing a program that will use stdin in
production.
Diego Olivier
next reply other threads:[~2012-06-04 18:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 18:59 Diego Olivier Fernandez Pons [this message]
2012-06-04 19:10 ` Gabriel Scherer
2012-06-04 19:12 ` Diego Olivier Fernandez Pons
2012-06-05 8:53 ` Goswin von Brederlow
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=CAHqiZ-+mJuOrtE03rftvrodxU4pfCfndQToJEHS0LRHa6Xwb-w@mail.gmail.com \
--to=dofp.ocaml@gmail.com \
--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