From: Ivan Gotovchits <ivg@ieee.org>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] GADT and locally ADT
Date: Tue, 04 Jun 2013 11:23:23 +0400 [thread overview]
Message-ID: <87a9n6s5jo.fsf@golf.niidar.ru> (raw)
In-Reply-To: <CAPFanBEau9FFNJAVF+9RyhfnbuLi+smcW3Hc6bk2BMxM3ysnnA@mail.gmail.com> (Gabriel Scherer's message of "Tue, 4 Jun 2013 07:47:06 +0200")
Gabriel Scherer <gabriel.scherer@gmail.com> writes:
> If the function knows (or infer) that the argument type is (ro), then
> there is only one case to handle. But there is also a function that is
> polymorphic over the second argument, and it must be callable with
> both (ro) and (rw) values : this function works "for any access mode".
> This is what the annotated function
>
>> let f (type t) (inp: ('a,t) access) = match inp with
>> | ReadWrite (ch) -> ()
>> | Read (ch) -> ();;
>
> does.
Looks reasonable, but can you, please, explain the difference between
function:
let f (type t) (inp: ('a,t) access) = match inp with
| ReadWrite ch -> ()
| Read ch -> ()
that have type
val f : ('a, 'b) access -> unit
and
let f (inp: ('a,'b) access) = match inp with
| ReadWrite ch -> ()
| Read ch -> ()
that fails to type check:
Error: This pattern matches values of type ('a, ro) access
but a pattern was expected which matches values of type
('a, rw) access
next prev parent reply other threads:[~2013-06-04 7:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 4:06 Ivan Gotovchits
2013-06-04 5:47 ` Gabriel Scherer
2013-06-04 7:23 ` Ivan Gotovchits [this message]
2013-06-04 9:23 ` Gabriel Scherer
2013-06-04 11:50 ` Ivan Gotovchits
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=87a9n6s5jo.fsf@golf.niidar.ru \
--to=ivg@ieee.org \
--cc=caml-list@inria.fr \
--cc=gabriel.scherer@gmail.com \
/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).