caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ernesto Posse <mposada@impsat.net.co>
To: Caml List <caml-list@pauillac.inria.fr>
Subject: Type constraints
Date: Thu, 29 May 1997 13:56:59 -0500	[thread overview]
Message-ID: <338DD17B.62C6@impsat.net.co> (raw)

[My apologies for not including a French Version]

Hello. I have the folowing problem. I need to define some interrelated
types as follows:

type 'a node = {x: 'a; y: t1}
and t1 = A | B of t1*t1
and t2 = C | D of (string * t2) node

The interpreter prints the inferred type:

type 'a node = { x: 'a; y: t1 } constraint 'a = string * t2
type t1 = | A | B of t1 * t1
type t2 = | C | D of (string * t2) node

Now, if I add another constructor:

type 'a node = {x: 'a; y: t1}
and t1 = A | B of t1*t1
and t2 = C | D of (string * t2) node | E of bool node

I obtain this message:

Characters 98-102:
This type parameter bool should be an instance of type string * t2

A solution to this would be something like:

type ('a,'b) node = {x: 'a; y: 'b}
and t1 = A | B of t1*t1
and t2 = C | D of (string * t2, t1) node | E of (bool, t1) node

This works, but I am not sure to understand the type clash in the former
example. Why did the type synthetizer infer that constraint?

Thank you for any insights on this.

-- 
Ernesto Posse
Ingeniero de Sistemas y Computacion
(Systems and Computing Engineer)
Universidad de los Andes
Santafe de Bogota
Colombia
e-mail: mposada@impsat.net.co





             reply	other threads:[~1997-05-30  6:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-29 18:56 Ernesto Posse [this message]
1997-05-30  7:41 ` Pascal Brisset
1997-05-30  9:24 ` Didier Rousseau
1997-05-30 10:01 ` Vale'rie Me'nissier-Morain
1997-05-30 11:09 ` Wolfgang Lux
1997-05-30 12:17 ` Jerome Vouillon
2004-12-06 19:55 Jim Farrand

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=338DD17B.62C6@impsat.net.co \
    --to=mposada@impsat.net.co \
    --cc=caml-list@pauillac.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).