caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Jim Farrand <jim@farrand.net>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Type indexed types?
Date: 26 Jan 2005 04:24:25 +1100	[thread overview]
Message-ID: <1106673863.28636.42.camel@pelican.wigram> (raw)
In-Reply-To: <1106672472.28636.20.camel@pelican.wigram>

On Wed, 2005-01-26 at 04:01, skaller wrote:
> On Tue, 2005-01-25 at 23:28, Jim Farrand wrote:

> > Note that I already have a function which can compute if type a is a
> > specialisation of type b.

The algorithm I have requires a comparison with 4 possible
results: less, greater, equal or incomparable. You can
derive that from just less-equal:

	match a <= b, b <= a with
	| true, true -> Equal
	| true, false -> Less
	| false, true -> Greater
	| false, false -> Incomparable

Unfortunately this requires two unification steps.
To use you own comment "There must be a better way" but
I don't know what it is.

BTW: I obtain this result by adding a constraint
to the unification algorithm that it only permits
equations of the form:

	'a = t

in the MGU, where 'a is a variable taken from the LHS of the
input equation (there is only a single equation when 
you're measuring 'less')

This is essential matching an function argument against a 
function signature (we want to reduce the signature to make
it equal to the argument).

However, when we're trying to order all the match
candidates, it would be nicer to get one of the
above four results in one unification step.

However it just won't work for an arbitrary MGU,
which might have the LHS variables coming from
either side of the equation. This can happen
if you get matching type variables. Unfortunately,
you can't just pick the LHS one every time,
since after substitution, an RHS variable
can end uo on the LHS .. :(

So I'd like to know if there is a better way to calculate
the four value partial ordering relation between two types
than two comparisons for less.. any hints?

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




  reply	other threads:[~2005-01-25 17:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-25 12:28 Jim Farrand
2005-01-25 17:01 ` [Caml-list] " skaller
2005-01-25 17:24   ` skaller [this message]
2005-01-25 17:49     ` skaller
2005-01-25 18:36       ` skaller
2005-01-25 18:37 ` brogoff

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=1106673863.28636.42.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=jim@farrand.net \
    /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).