How to make Claessen's Refs Ord-able?

Koen Claessen koen@cs.chalmers.se
Thu, 21 Mar 2002 09:49:21 +0100 (MET)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

---559023410-1804928587-1016700561=:26079
Content-Type: TEXT/PLAIN; charset=US-ASCII


 | I'd like to extend the Ref type for observable sharing
 | of Koen Claessen's Ph.D. thesis: to make it possible
 | for the Refs to be the keys for efficient finite maps.

I did this in the Lava implementation. The Ref module I
attach works in Hugs and GHC.

/Koen.

---559023410-1804928587-1016700561=:26079
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="Ref.hs"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.4.30.0203210949210.26079@hotlips.cs.chalmers.se>
Content-Description: 
Content-Disposition: attachment; filename="Ref.hs"

bW9kdWxlIFJlZg0KICAoIFJlZiAgICAgICAtLSAqIC0+ICogOyBFcSwgU2hv
dw0KICAsIHJlZiAgICAgICAtLSA6OiBhICAgICAtPiBSZWYgYQ0KICAsIGRl
cmVmICAgICAtLSA6OiBSZWYgYSAtPiBhDQogICwgbWVtb1JlZiAgIC0tIDo6
IChSZWYgYSAtPiBiKSAtPiAoUmVmIGEgLT4gYikNCiAgDQogICwgVGFibGVJ
TyAgIC0tIDo6ICogLT4gKiAtPiAqIDsgRXENCiAgLCB0YWJsZUlPICAgLS0g
OjogSU8gKFRhYmxlSU8gYSBiKQ0KICAsIGV4dGVuZElPICAtLSA6OiBUYWJs
ZUlPIGEgYiAtPiBSZWYgYSAtPiBiIC0+IElPICgpDQogICwgZmluZElPICAg
IC0tIDo6IFRhYmxlSU8gYSBiIC0+IFJlZiBhIC0+IElPIChNYXliZSBiKQ0K
ICAsIG1lbW9SZWZJTyAtLSA6OiAoUmVmIGEgLT4gSU8gYikgLT4gKFJlZiBh
IC0+IElPIGIpDQoNCiAgLCBUYWJsZVNUICAgLS0gOjogKiAtPiAqIC0+ICog
LT4gKi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gICAgICAgICBKdXN0IGIgIC0+IGRvIHJldHVybiBiDQogICAg
ICAgICAgICAgICAgICAgICBOb3RoaW5nIC0+IGZpeFNUICQgXGIgLT4NCiAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkbyBleHRlbmRTVCB0
YWIgciBiDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ZiByDQogICAgIHJldHVybiBmJw0KDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0K
LS0gRHluDQoNCmRhdGEgRHluDQogID0gRHluDQoNCnRvRHluIDo6IGEgLT4g
RHluDQp0b0R5biA9IHVuc2FmZUNvZXJjZQ0KDQpmcm9tRHluIDo6IER5biAt
PiBhDQpmcm9tRHluID0gdW5zYWZlQ29lcmNlDQoNCi0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tDQotLSB0aGUgZW5kLg0KDQoNCg0K
---559023410-1804928587-1016700561=:26079--