caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Keiko Nakata <keiko@kurims.kyoto-u.ac.jp>
To: garrigue@math.nagoya-u.ac.jp
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] private rows question
Date: Fri, 11 Nov 2005 14:42:47 +0900 (JST)	[thread overview]
Message-ID: <20051111.144247.68530040.keiko@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <20051111.141222.106258050.garrigue@math.nagoya-u.ac.jp>

From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>

> From: Keiko Nakata <keiko@kurims.kyoto-u.ac.jp>
> 
> > Why the following functor G is not typable?
> > I thought that g could have a type something like int -> [< `A | `B ].
> > 
> > module G(X:sig type t = private [< `A ] val f : int -> t end) = struct
> >   let g x = if x = 0 then `B else X.f x 
> > end
> 
> Since g may return `B, and probably `A (the probably concerns your
> intention), the expected type would be
>   g : int -> [> `A | `B ]
> Next, if you want f to have a private row type, then you should
> disconnect its type from the type of g (otherwise the type of g must
> be the same as f.) So I would expect something like:
>    let g x = if x = 0 then `B else (X.f x : [< `A] :> [> `A])

Thank you for the correction.
Obviously, the type checker is much more brilliant than me :-)
Private rows seem to give me more opportunities to reuse my program codes
than I expected.

Keiko NAKATA


  reply	other threads:[~2005-11-11  5:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-10  3:50 Keiko Nakata
2005-11-11  5:12 ` [Caml-list] " Jacques Garrigue
2005-11-11  5:42   ` Keiko Nakata [this message]
2005-11-11  6:27     ` [Caml-list] again " Keiko Nakata

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=20051111.144247.68530040.keiko@kurims.kyoto-u.ac.jp \
    --to=keiko@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).