caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
To: Misha Aizatulin <avatar@hot.ee>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] typechecking
Date: Sat, 22 Mar 2014 21:40:15 +0100	[thread overview]
Message-ID: <2E564C20A45F40FFA6BDB6946F088F03@erratique.ch> (raw)
In-Reply-To: <532DEC4E.6040505@hot.ee>

Le samedi, 22 mars 2014 à 21:02, Misha Aizatulin a écrit :
> type t1 = T1
> type t2 = T2
>  
> let f T2 = ()
>  
> let input (c : in_channel) : t1 =
> let t = input_value c in
> f t;
> t

Unmarshaling is not type-safe, you always need to add a type annotation when you input_value. See the warning in the documentation here [1]. Your program should read:

type t1 = T1
type t2 = T2

let f T2 = ()

let input (c : in_channel) : t1 =
let t = (input_value c : t1) in
f t;
t



Which the compiler rejects.  

Best,

Daniel

[1] http://caml.inria.fr/pub/docs/manual-ocaml-4.01/libref/Marshal.html

  reply	other threads:[~2014-03-22 20:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-22 20:02 Misha Aizatulin
2014-03-22 20:40 ` Daniel Bünzli [this message]
2014-03-22 22:12   ` Yaron Minsky
2014-03-22 22:24     ` Jonathan Protzenko
2014-03-23  4:41 ` oleg
2014-03-23 12:59   ` Jacques Garrigue
2014-03-24  8:46     ` Alain Frisch

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=2E564C20A45F40FFA6BDB6946F088F03@erratique.ch \
    --to=daniel.buenzli@erratique.ch \
    --cc=avatar@hot.ee \
    --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).