caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Berke Durak <berke.durak@exalead.com>
To: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
Cc: Caml-list List <caml-list@inria.fr>
Subject: Re: [Caml-list] How to make a value uncomparable
Date: Wed, 23 Apr 2008 18:14:58 +0200	[thread overview]
Message-ID: <480F6082.6030901@exalead.com> (raw)
In-Reply-To: <480F578F.9040403@univ-savoie.fr>

Christophe Raffalli wrote:
>> =20
>> module Uncomparable :
>>   sig
>>     type 'a t
>>     val make : 'a -> 'a t
>>     val get : 'a t -> 'a
>>   end
>>   =3D
>>   struct
>>     type 'a t =3D unit -> 'a
>> =20
>>     let make x =3D fun _ -> x
>> =20
>>     let get x =3D x ()
>>   end
>> =20

Indeed, that's a much simpler solution! :)

But there's one minor difference: physical equality works on Weak.t but not on
functions.  But that can be handled by using a ref to a function.

module Structurally_uncomparable :
   sig
     type 'a t
     val make : 'a -> 'a t
     val get : 'a t -> 'a
   end
   =
   struct
     type 'a t = (unit -> 'a) ref
     let make x = ref (fun _ -> x)
     let get x = (!x)()
   end

-- 
Berke DURAK


  reply	other threads:[~2008-04-23 16:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-23 13:49 Berke Durak
2008-04-23 15:36 ` [Caml-list] " Christophe Raffalli
2008-04-23 16:14   ` Berke Durak [this message]
2008-04-23 16:49     ` Christophe Raffalli
2008-04-23 17:43       ` Berke Durak
2008-04-23 17:46         ` Jon Harrop

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=480F6082.6030901@exalead.com \
    --to=berke.durak@exalead.com \
    --cc=caml-list@inria.fr \
    --cc=christophe.raffalli@univ-savoie.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).