[GUI] Example for thought

David Sankel camio@yahoo.com
Thu, 3 Apr 2003 08:53:54 -0800 (PST)


--0-1228435925-1049388834=:140
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

--- David Sankel <camio@yahoo.com> wrote:
> What would a haskell solution look like?  In my
> opinion this functionality would be very desirable
> if
> not required.
> 
Here is one solution using normal MVars.  It is IMHO
uglier than the c++ version.  I think creating an
extention of MVars to allow callbacks on change and
syncronized variables would be very nice with this
example problem.  I would also suggest removing the
empty MVar status.
--0-1228435925-1049388834=:140
Content-Type: application/octet-stream; name="Test.hs"
Content-Transfer-Encoding: base64
Content-Description: Test.hs
Content-Disposition: attachment; filename="Test.hs"

bW9kdWxlIG1haW4obWFpbikgd2hlcmUKCmltcG9ydCBDR0EuU3BpbkJveApp
bXBvcnQgQ0dBLldpbmRvdwoKbWFpbiA9IGNnYUJlZ2luICQgZG8KICBteUlu
dCA8LSBuZXdNVmFyIE15SW50IDQgW10gLS1UaGUgaW5pdGlhbCB2YWx1ZSBv
ZiBpbnQgdmFyaWFibGUKICBkb09uQ2hhbmdlIG15SW50IChkbwogICAgICAg
ICAgICAgICAgICAgICAgIGEgPC0gZ2V0VmFsIG15SW50CiAgICAgICAgICAg
ICAgICAgICAgICAgcHV0U3RyIChzaG93IGEpCiAgICAgICAgICAgICAgICAg
ICAgKSAtLVRoaXMgc2hvd3MgbXlJbnQgb24gdGhlIHNjcmVlbiB3aGVuZXZl
ciBpdCBpcyBjaGFuZ2VkCiAgLS0gVGhlIGZvbGxvd2luZyB0d28gbGluZXMg
cHV0IHRoZSBNeUludCBpbnRlcmZhY2UgaW4gYSB3aW5kb3cKICBpbnRlcmZh
Y2UgPC0gbWFrZV9pbnRlcmZhY2UgbXlJbnQgCiAgd2luZG93IDwtIG5ld1dp
bmRvdyBbIHRpdGxlIDo9ICJzcGluYm94IHRlc3QiLCBhZGRDaGlsZCA6PSBp
bnRlcmZhY2UgXQoKY2xhc3MgT2JqZWN0IGEgd2hlcm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