[From nobody Wed Jun 20 15:24:20 2007
Received: from circe.telenet-ops.be (circe.telenet-ops.be [195.130.132.51])
	by nocme2bl8.telenet-ops.be (Postfix) with ESMTP id 8AD6A158034
	for &lt;bf3@telenet.be&gt;; Sat, 16 Jun 2007 01:50:52 +0200 (CEST)
Received: from localhost (localhost.localdomain [127.0.0.1])
	by nocme2bl8.telenet-ops.be (Postfix) with SMTP id 90DBA158037
	for &lt;bf3@telenet.be&gt;; Sat, 16 Jun 2007 01:50:52 +0200 (CEST)
Received: from relay1.mail.ox.ac.uk (relay1.mail.ox.ac.uk [129.67.1.165])
	by circe.telenet-ops.be (Postfix) with ESMTP id 8311233E8E
	for &lt;bf3@telenet.be&gt;; Sat, 16 Jun 2007 01:50:52 +0200 (CEST)
Received: from dhcp0714.gradacc.ox.ac.uk ([129.67.90.202] helo=localhost)
	by smtp0.mail.ox.ac.uk with esmtp (Exim 4.63)
	(envelope-from &lt;duncan.coutts@worc.ox.ac.uk&gt;)
	id 1HzLZ5-0004df-1y; Sat, 16 Jun 2007 00:50:51 +0100
Received: from smtp0.mail.ox.ac.uk ([129.67.1.205])
	by relay1.mail.ox.ac.uk with esmtp (Exim 4.62)
	(envelope-from &lt;duncan.coutts@worc.ox.ac.uk&gt;)
	id 1HzLZ6-0002lY-3K; Sat, 16 Jun 2007 00:50:52 +0100
Received: from nocme2bl8.telenet-ops.be (nocme2bl8.telenet-ops.be
	[195.130.136.12])
	by hoboi2bl5.telenet-ops.be (8.13.1/8.13.1) with ESMTP id
	l5FNoqil030050 for &lt;bf3@telenet.be&gt;; Sat, 16 Jun 2007 01:50:52 +0200
Received: (qmail 23620 invoked from network); 15 Jun 2007 23:50:54 -0000
Received: from hoboi2bl5.telenet-ops.be ([195.130.137.88])
	(envelope-sender &lt;duncan.coutts@worc.ox.ac.uk&gt;)
	by kreusa.telenet-ops.be (qmail-ldap-1.03) with SMTP
	for &lt;bf3@telenet.be&gt;; 15 Jun 2007 23:50:54 -0000
Return-Path: &lt;duncan.coutts@worc.ox.ac.uk&gt;
From: &quot;Duncan Coutts&quot; &lt;duncan.coutts@worc.ox.ac.uk&gt;
To: &lt;bf3@telenet.be&gt;
Cc: &lt;haskell-cafe@haskell.org&gt;
References: &lt;001f01c7af92$3eafe7b0$bc0fb710$@be&gt;
In-Reply-To: &lt;001f01c7af92$3eafe7b0$bc0fb710$@be&gt;
Subject: Re: [Haskell-cafe] GHCI hangs on Gtk2HS SOE on Windows,
	but GHC	works fine?
Date: Sat, 16 Jun 2007 01:50:12 +0200
Message-ID: &lt;1181951412.5026.83.camel@localhost&gt;
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary=&quot;----=_NextPart_000_004D_01C7B382.1EBE3210&quot;
X-Mailer: Evolution 2.6.1 
X-SpamCatcher-Score: 64 [XX]
Thread-Index: AcevqALRwx68OGdfQn+GrPTeXC07Lg==

This is a multipart message in MIME format.

------=_NextPart_000_004D_01C7B382.1EBE3210
Content-Type: text/plain;
	charset=&quot;iso-8859-1&quot;
Content-Transfer-Encoding: 7bit

On Fri, 2007-06-15 at 23:15 +0200, bf3@telenet.be wrote:
&gt; I'm learning Haskell using Paul Hudak's book SOE. 
&gt; 
&gt; I'm using GHC 6.6 under Windows XP.
&gt; 
&gt; GHC on Windows does not seem to come with HGL (is this correct?), so I
used
&gt; Gtk2HS, which contains a SOE implementation.
&gt; 
&gt; I noticed that most programs hang when using GHCI, but they work fine with
&gt; GHC.

It's not GHCi's fault as such. The reason it does not work well in GHCi
at the moment is a bit technical. The Gtk2Hs SOE implementation
currently uses Haskell threads. Like most GUI toolkits, Gtk+ is single
threaded and requires special attention to use it from multiple OS
threads. Currently, by default, GHC produces executables that use the
single-threaded runtime system, and this works fine with multiple
Haskell threads because they get multiplexed on the same OS thread. GHC
can however produce executables that use the multi-threaded runtime
system and ghci.exe itself is such a program. So when you use SOE with
GHCi it's actually using multiple threads to access Gtk+ an not in a
safe way, so it goes wrong in a myriad of ways.

I'll take another look at trying to make the SOE stuff work with the
threaded runtime system by using the primitives Gtk2Hs provides to use
Gtk+ safely from multiple threads.

Duncan


------=_NextPart_000_004D_01C7B382.1EBE3210
Content-Type: text/html;
	charset=&quot;iso-8859-1&quot;
Content-Transfer-Encoding: quoted-printable

&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 3.2//EN&quot;&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;META HTTP-EQUIV=3D&quot;Content-Type&quot; CONTENT=3D&quot;text/html; =
charset=3Diso-8859-1&quot;&gt;
&lt;META NAME=3D&quot;Generator&quot; CONTENT=3D&quot;MS Exchange Server version =
08.00.0681.000&quot;&gt;
&lt;TITLE&gt;Re: [Haskell-cafe] GHCI hangs on Gtk2HS SOE on Windows, but GHC	=
works fine?&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;!-- Converted from text/plain format --&gt;

&lt;P&gt;&lt;FONT SIZE=3D2&gt;On Fri, 2007-06-15 at 23:15 +0200, bf3@telenet.be =
wrote:&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; I'm learning Haskell using Paul Hudak's book =
SOE. &lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; &lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; I'm using GHC 6.6 under Windows XP.&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; &lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; GHC on Windows does not seem to come with HGL =
(is this correct?), so I used&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; Gtk2HS, which contains a SOE =
implementation.&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; &lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; I noticed that most programs hang when using =
GHCI, but they work fine with&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;&amp;gt; GHC.&lt;/FONT&gt;
&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=3D2&gt;It's not GHCi's fault as such. The reason it does not =
work well in GHCi&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;at the moment is a bit technical. The Gtk2Hs SOE =
implementation&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;currently uses Haskell threads. Like most GUI =
toolkits, Gtk+ is single&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;threaded and requires special attention to use it =
from multiple OS&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;threads. Currently, by default, GHC produces =
executables that use the&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;single-threaded runtime system, and this works fine =
with multiple&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;Haskell threads because they get multiplexed on the =
same OS thread. GHC&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;can however produce executables that use the =
multi-threaded runtime&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;system and ghci.exe itself is such a program. So when =
you use SOE with&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;GHCi it's actually using multiple threads to access =
Gtk+ an not in a&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;safe way, so it goes wrong in a myriad of =
ways.&lt;/FONT&gt;
&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=3D2&gt;I'll take another look at trying to make the SOE stuff =
work with the&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;threaded runtime system by using the primitives =
Gtk2Hs provides to use&lt;/FONT&gt;

&lt;BR&gt;&lt;FONT SIZE=3D2&gt;Gtk+ safely from multiple threads.&lt;/FONT&gt;
&lt;/P&gt;

&lt;P&gt;&lt;FONT SIZE=3D2&gt;Duncan&lt;/FONT&gt;
&lt;/P&gt;

&lt;/BODY&gt;
&lt;/HTML&gt;
------=_NextPart_000_004D_01C7B382.1EBE3210--
]