From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=5.0 tests=AWL,DNS_FROM_RFC_POST, HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B29ACBBAF for ; Fri, 26 Jun 2009 07:44:25 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgcDADv9Q0rRVdvNlGdsb2JhbACCIzGVYz8BAQEBCQkKCRGkaYEZkCsBAwIEhAkF X-IronPort-AV: E=Sophos;i="4.42,294,1243807200"; d="scan'208";a="42450657" Received: from mail-ew0-f205.google.com ([209.85.219.205]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Jun 2009 07:44:25 +0200 Received: by ewy1 with SMTP id 1so1683758ewy.27 for ; Thu, 25 Jun 2009 22:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=MA58vczYnTrQN8Hff9C0yobn01MPutjuREHIRb0sonk=; b=ROIgxKxdIlEAX0aXidbZj+L7KIN0drzxMuh5B6SX0MIluXOY8wOn+odiF0wS8DOjfx q7O8PE2lW0/fcofNx5LHdXTbTj2oeaDBZ/LLOHRWKB1JT2kj0w+mI6NfRIafCb/aZiRf cuQTpCq1eFHSJwUIQXmlkFdZMn0d+vNCE3+go= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=HinAc4dUWA1RkbXzEUWXO1mgqqAWvptrFmQEYKMoLQfgupEdA4CVKPJx7ptN6p3VhF 2L+pxzDi4isScq7Tcf8tjUIvE4uPiDESZRJhTWnsEf2VAgc937Sffh8bsDGP+E4cZLTj HHqctleAQbYsn5NTKSpidQra4QgrDbs9Rkqvg= MIME-Version: 1.0 Received: by 10.216.24.141 with SMTP id x13mr1013280wex.106.1245995064694; Thu, 25 Jun 2009 22:44:24 -0700 (PDT) Date: Fri, 26 Jun 2009 01:44:24 -0400 Message-ID: Subject: A copy/paste buffer From: Jacques Le Normand To: caml-list caml-list Content-Type: multipart/alternative; boundary=0016e6dbe88939185d046d39d580 X-Spam: no; 0.00; buffer:01 buffer:01 variants:01 foo:01 endline:01 cheers:01 variants:01 foo:01 endline:01 cheers:01 polymorphic:01 polymorphic:01 caml-list:01 caml-list:01 arbitrary:02 --0016e6dbe88939185d046d39d580 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello caml-list, I want to implement a copy/paste buffer for arbitrary polymorphic variants. Is the following code safe? " let buffer : 'a = Obj.magic (ref None) let _ = buffer := Some `Foo let _ = buffer := Some `Bar let _ = match !buffer with Some (`Bar x) -> print_endline "matches" | _ -> () " also, how would I refine the buffer type a little more? Every time I try, I run into the value restriction cheers --Jacques L. --0016e6dbe88939185d046d39d580 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello caml-list,
I want to implement a copy/paste buffer for arbitrary p= olymorphic variants. Is the following code safe?


"
let b= uffer=A0 : 'a =3D Obj.magic (ref None)
=A0=A0=A0
let _ =3D buff= er :=3D Some `Foo
let _ =3D buffer :=3D Some `Bar

let _ =3D
=A0 match !buffer with=
=A0=A0=A0=A0=A0 Some (`Bar x) -> print_endline "matches"=A0=A0=A0 | _ -> ()
"


also, how would I refine the = buffer type a little more? Every time I try, I run into the value restricti= on
cheers
--Jacques L.
--0016e6dbe88939185d046d39d580--