caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
To: Andrew <newsgroups.fr@gmail.com>,
	Caml Mailing List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Weak array semantics with mutually recursive values.
Date: Sat, 22 Jan 2011 20:41:36 +0100	[thread overview]
Message-ID: <4D3B32F0.6080107@univ-savoie.fr> (raw)
In-Reply-To: <4d3b1a5d.ccefd80a.600d.177e@mx.google.com>


[-- Attachment #1.1: Type: text/plain, Size: 1645 bytes --]

Le 22/01/11 18:56, Andrew a écrit :
>> let rec x = (1,y) and y = (2,x)

This was just a silly example, but -rectypes works in that case.

My real example is a type for hashconsed propositional formula
each formula pointing to its negation like this (ignoring hashconsing):

this is untested ...

type form =
Lit(bool * string*form)
| Conj(form*form*form)
| Disj(form*form*form)

let mkNot = function
  Lit(_,_,f) | Conj(_,_,f) | Disj(_,_,f) -> f

let mkLit v =
  let rec v1 = Lit(true,v,v2) and v2 = Lit(false,v,v1) in v1

let mkConj f1 f2 =
  let rec v1 = Conj(f1,f2,v2) and v2 = Disj(mkNot f1, mkNot f2, v1) in v1

So the real question is what is the best way to hashcons this ?

> Might be naïve curiosity, but how do you manage to build this? What's the
> type of x and y?
>
> My Ocaml toplevel returns 
>     # let rec x = (1,y) and y = (2,x);;
>     Characters 26-31:
>       let rec x = (1,y) and y = (2,x);;
>                                 ^^^^^
>     Error: This expression has type int * (int * (int * 'a))
>            but is here used with type int * 'a
>
> Andrew.
>
>


-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution 
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------


[-- Attachment #1.2: Christophe_Raffalli.vcf --]
[-- Type: text/x-vcard, Size: 310 bytes --]

begin:vcard
fn:Christophe Raffalli
n:Raffalli;Christophe
org:LAMA (UMR 5127)
email;internet:christophe.raffalli@univ-savoie.fr
title;quoted-printable:Ma=C3=AEtre de conf=C3=A9rences
tel;work:+33 4 79 75 81 03
note:http://www.lama.univ-savoie.fr/~raffalli
x-mozilla-html:TRUE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

  parent reply	other threads:[~2011-01-22 19:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-22 16:29 Christophe Raffalli
     [not found] ` <4d3b1a5d.ccefd80a.600d.177e@mx.google.com>
2011-01-22 19:41   ` Christophe Raffalli [this message]
2011-01-24 12:45 ` Damien Doligez
2011-01-24 21:41   ` Christophe Raffalli
2011-01-26 13:13     ` Damien Doligez

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=4D3B32F0.6080107@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=newsgroups.fr@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).