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

Jacques


  reply	other threads:[~2005-11-11  5:11 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 ` Jacques Garrigue [this message]
2005-11-11  5:42   ` [Caml-list] " Keiko Nakata
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.141222.106258050.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=keiko@kurims.kyoto-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).