That is kind of what I thought you were doing.<br><br>Retooling to see if we can get any better performance out of collecting, it seems that System.Mem.PerformGC does a foreign call out to performMajorGC to ask for a global collection. But I would hazard that you might be able to get most of the benefit by just asking for the nursery to be cleaned up. <br>
<br>To that end, perhaps it would be worthwhile to consider switching to something like:<br><span class="keyword"><br>foreign</span> <span class="keyword">import</span> <span class="keyword">ccall</span> <span class="comment">{-safe-}</span> <span class="str">&quot;performGC&quot;</span> <span class="varid">performMinorGC</span> <span class="keyglyph">::</span> <span class="conid">IO</span> <span class="conid">()</span><br>
<br>-- System.Mem imports performMajorGC as &#39;performGC&#39; but the minor collection appears to be called performGC, hence the rename.<br><br>This should let you call for a minor collection, which should be considerably less time consuming. Especially as if you call it frequently you&#39;ll be dealing with a mostly cleared nursery anyways.<br>
<br>-Edward Kmett<br><br><div class="gmail_quote">On Thu, Jan 7, 2010 at 4:39 PM, Miguel Mitrofanov <span dir="ltr">&lt;<a href="mailto:miguelimo38@yandex.ru">miguelimo38@yandex.ru</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I liked it too. Seems like I have to show some real code, and my apologies for a long e-mail.<br>
<br>
Well, that&#39;s what I&#39;m actually trying to do and what I&#39;ve managed to achieve so far.<br>
<br>
&gt; module Ask where<br>
&gt; import Control.Monad<br>
&gt; import Data.IORef<br>
&gt; import Data.Maybe<br>
&gt; import System.IO.Unsafe -- Yes, I would need that<br>
&gt; import System.Mem<br>
&gt; import System.Mem.Weak<br>
<br>
Suppose we&#39;re writing a RESTful server, which keeps all state on the client. We want it to send questions to the client and get back the answers. We can also send some state data to the client and we are sure that the client would return them back unchanged. So, that&#39;s the type of our server:<br>

<br>
&gt; type Server medium = Maybe (medium, String) -&gt; IO (Maybe (medium, String))<br>
<br>
The client starts interaction, sending &quot;Nothing&quot;; when server finally returns &quot;Nothing&quot;, the session stops. I would emulate the client in GHCi with the following function:<br>
<br>
&gt; client :: Show medium =&gt; Bool -&gt; Server medium -&gt; IO ()<br>
&gt; client debug server = client&#39; Nothing where<br>
&gt;     client&#39; query =<br>
&gt;         do response &lt;- server query<br>
&gt;            case response of<br>
&gt;              Nothing -&gt; return ()<br>
&gt;              Just (medium, question) -&gt;<br>
&gt;                  do when debug $ putStr &quot;Debug: &quot; &gt;&gt; print medium<br>
&gt;                     putStrLn question<br>
&gt;                     putStr &quot;--&gt; &quot;<br>
&gt;                     answer &lt;- getLine<br>
&gt;                     client&#39; $ Just (medium, answer)<br>
<br>
Nothing very interesting. The only thing to note is that the boolean argument allows us to see the state sent by server - for debugging purposes.<br>
<br>
But I want something more high-level. The goal is to solve the Graham&#39;s &quot;arc challenge&quot;. So the high-level interface is implemented by this type:<br>
<br>
&gt; data Ask a = Finish a | Continue String (String -&gt; Ask a)<br>
<br>
A possible application would be:<br>
<br>
&gt; test :: Ask ()<br>
&gt; test =<br>
&gt;     do s1 &lt;- ask &quot;Enter the first number&quot;<br>
&gt;        let n1 = read s1<br>
&gt;        s2 &lt;- ask &quot;Enter the second number&quot;<br>
&gt;        let n2 = read s2<br>
&gt;        ask $ show $ n1 + n2<br>
&gt;        return ()<br>
<br>
Well, to do that, I need a Monad instance for Ask:<br>
<br>
&gt; instance Monad Ask where<br>
&gt;     return = Finish<br>
&gt;     Finish x &gt;&gt;= h = h x<br>
&gt;     Continue question k &gt;&gt;= h = Continue question $ \answer -&gt; k answer &gt;&gt;= h<br>
<br>
and an &quot;ask&quot; function:<br>
<br>
&gt; ask :: String -&gt; Ask String<br>
&gt; ask question = Continue question $ \answer -&gt; return answer<br>
<br>
Now, the problem is with the route from high level to the low level. We can do it relatively simply:<br>
<br>
&gt; simpleServer :: Ask () -&gt; Server [String]<br>
&gt; simpleServer anything = return . simpleServer&#39; anything . maybe [] (\(medium, answer) -&gt; medium ++ [answer]) where<br>
&gt;     simpleServer&#39; (Finish ()) _ = Nothing<br>
&gt;     simpleServer&#39; (Continue question _) [] = Just ([], question)<br>
&gt;     simpleServer&#39; (Continue _ k) (s : ss) =<br>
&gt;         do (medium, question) &lt;- simpleServer&#39; (k s) ss<br>
&gt;            return (s : medium, question)<br>
<br>
And indeed, our test example works:<br>
<br>
*Ask&gt; client False $ simpleServer test<br>
Enter the first number<br>
--&gt; 3<br>
Enter the second number<br>
--&gt; 4<br>
7<br>
--&gt;<br>
<br>
But, as you&#39;ve probably guessed already, this &quot;simpleServer&quot; sends way too much information over network:<br>
<br>
&gt; nonsense :: Ask ()<br>
&gt; nonsense =<br>
&gt;     do a &lt;- ask &quot;?&quot;<br>
&gt;        b &lt;- ask a<br>
&gt;        c &lt;- ask b<br>
&gt;        d &lt;- ask c<br>
&gt;        e &lt;- ask b -- Note this &quot;b&quot; instead of &quot;d&quot;, it&#39;s deliberate.<br>
&gt;        return ()<br>
<br>
*Ask&gt; client True $ simpleServer nonsense<br>
Debug: []<br>
?<br>
--&gt; a<br>
Debug: [&quot;a&quot;]<br>
a<br>
--&gt; b<br>
Debug: [&quot;a&quot;,&quot;b&quot;]<br>
b<br>
--&gt; c<br>
Debug: [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]<br>
c<br>
--&gt; d<br>
Debug: [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;]<br>
b<br>
--&gt; e<br>
<br>
All user answers from the very beginning get transmitted.<br>
<br>
I want to transmit only those answers that are actually used. I&#39;m gonna write another server, a (relatively) smart one.<br>
<br>
A simple boxing type:<br>
<br>
&gt; data Box a = Box {unBox :: a}<br>
<br>
Now, the server. I use &quot;Nothing&quot; for those user answers that are no longer needed.<br>
<br>
&gt; smartServer :: Ask () -&gt; Server [Maybe String]<br>
&gt; smartServer anything = smartServerIO anything . maybe [] (\(medium, answer) -&gt; medium ++ [Just answer]) where<br>
&gt;     smartServerIO anything query =<br>
<br>
Sometimes a value is not used anymore just because it WAS used already. So I&#39;ll use a mutable list to keep track of those values that are actually dereferenced:<br>
<br>
&gt;         do usedList &lt;- newIORef []<br>
<br>
Then, I&#39;ll make weak pointers for all user answers:<br>
<br>
&gt;            let boxedQuery = map Box query<br>
&gt;            weakPtrs &lt;- mapM (\box -&gt; mkWeak box () Nothing) boxedQuery<br>
<br>
and actually run my &quot;Ask&quot; value.<br>
<br>
&gt;            case findWeakPtrs 0 anything boxedQuery usedList of<br>
&gt;              Finish () -&gt; return Nothing<br>
&gt;              Continue question rest -&gt;<br>
<br>
Now, the interesting part. I&#39;d invoke a garbage collector to get rid of those boxes that aren&#39;t necessary anymore.<br>
<br>
&gt;                  do performGC<br>
<br>
Now, weak pointers tell me what boxes are not dereferenced but can be dereferenced in the future, and my mutable list has the numbers of boxes that were dereferenced.<br>
<br>
&gt;                     danglingNumbers &lt;- mapM deRefWeak weakPtrs<br>
&gt;                     usedNumbers &lt;- readIORef usedList<br>
<br>
I also need to keep this &quot;future&quot; alive, so that usable boxes don&#39;t get garbage collected.<br>
<br>
&gt;                     case rest undefined of _ -&gt; return ()<br>
<br>
And now all I need to do is to filter out those boxes that are not in any of the two lists:<br>
<br>
&gt;                     return $ Just (zipWith3 (isUsed usedNumbers) [0..] danglingNumbers query, question)<br>
<br>
Helper function has an interesting detail:<br>
<br>
&gt;     findWeakPtrs _ (Finish ()) _ _ = Finish ()<br>
&gt;     findWeakPtrs _ response [] _ = response<br>
<br>
I use unsafePerformIO to track those boxes that get actually dereferenced:<br>
<br>
&gt;     findWeakPtrs n (Continue _ k) (s : ss) usedList =<br>
&gt;         findWeakPtrs (n+1) (k (unsafePerformIO $ modifyIORef usedList (n :) &gt;&gt; return (fromJust $ unBox s))) ss usedList<br>
<br>
A filtering function is not very interesting:<br>
<br>
&gt;     isUsed usedNumbers index Nothing _ | not (index `elem` usedNumbers) = Nothing<br>
&gt;     isUsed _ _ _ answer = answer<br>
<br>
And it works:<br>
<br>
*Ask&gt; client True $ smartServer nonsense<br>
Debug: []<br>
?<br>
--&gt; a<br>
Debug: [Just &quot;a&quot;]<br>
a<br>
--&gt; b<br>
Debug: [Nothing,Just &quot;b&quot;]<br>
b<br>
--&gt; c<br>
Debug: [Nothing,Just &quot;b&quot;,Just &quot;c&quot;]<br>
c<br>
--&gt; d<br>
Debug: [Nothing,Just &quot;b&quot;,Nothing,Nothing]<br>
b<br>
--&gt; e<br>
<br>
So, the problem is, I don&#39;t think calling performGC every time is a good idea. I&#39;d like to tell explicitly what values are to be garbage collected. It doesn&#39;t seem like it&#39;s possible with current version of GHC, though.<div>
<div></div><div class="h5"><br>
<br>
On 7 Jan 2010, at 23:07, Edward Kmett wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thats a shame, I was rather fond of this monad. To get that last &#39;True&#39;, you&#39;ll really have to rely on garbage collection to approximate reachability for you, leaving the weak reference solution the best you can hope for.<br>

<br>
-Edward Kmett<br>
<br>
On Thu, Jan 7, 2010 at 12:39 PM, Miguel Mitrofanov &lt;<a href="mailto:miguelimo38@yandex.ru" target="_blank">miguelimo38@yandex.ru</a>&gt; wrote:<br>
Damn. Seems like I really need (True, False, True) as a result of &quot;test&quot;.<br>
<br>
<br>
On 7 Jan 2010, at 08:52, Miguel Mitrofanov wrote:<br>
<br>
Seems very nice. Thanks.<br>
<br>
On 7 Jan 2010, at 08:01, Edward Kmett wrote:<br>
<br>
Here is a slightly nicer version using the Codensity monad of STM.<br>
<br>
Thanks go to Andrea Vezzosi for figuring out an annoying hanging bug I was having.<br>
<br>
-Edward Kmett<br>
<br>
{-# LANGUAGE Rank2Types, GeneralizedNewtypeDeriving, DeriveFunctor #-}<br>
module STMOracle<br>
  ( Oracle, Ref<br>
  , newRef, readRef, writeRef, modifyRef, needRef<br>
  ) where<br>
<br>
import Control.Applicative<br>
import Control.Monad<br>
import Control.Concurrent.STM<br>
<br>
instance Applicative STM where<br>
  pure = return<br>
  (&lt;*&gt;) = ap<br>
<br>
newtype Ref s a = Ref (TVar (Maybe a))<br>
newtype Oracle s a = Oracle { unOracle :: forall r. (a -&gt; STM r) -&gt; STM r } deriving (Functor)<br>
<br>
instance Monad (Oracle s) where<br>
 return x = Oracle (\k -&gt; k x)<br>
 Oracle m &gt;&gt;= f = Oracle (\k -&gt; m (\a -&gt; unOracle (f a) k))<br>
<br>
mkOracle m = Oracle (m &gt;&gt;=)<br>
<br>
runOracle :: (forall s. Oracle s a) -&gt; IO a<br>
runOracle t = atomically (unOracle t return)<br>
<br>
newRef :: a -&gt; Oracle s (Ref s a)<br>
newRef a = mkOracle $ Ref &lt;$&gt; newTVar (Just a)<br>
<br>
readRef :: Ref s a -&gt; Oracle s a<br>
readRef (Ref r) = mkOracle $ do<br>
  m &lt;- readTVar r<br>
  maybe retry return m<br>
<br>
writeRef :: a -&gt; Ref s a -&gt; Oracle s a<br>
writeRef a (Ref r) = mkOracle $ do<br>
  writeTVar r (Just a)<br>
  return a<br>
<br>
modifyRef :: (a -&gt; a) -&gt; Ref s a -&gt; Oracle s a<br>
modifyRef f r = do<br>
  a &lt;- readRef r<br>
  writeRef (f a) r<br>
<br>
needRef :: Ref s a -&gt; Oracle s Bool<br>
needRef (Ref slot) = Oracle $ \k -&gt;<br>
           (writeTVar slot Nothing &gt;&gt; k False)<br>
  `orElse` k True<br>
<br>
-- test case:                                                                                                                               refMaybe b dflt ref = if b then readRef ref else return dflt<br>
refIgnore ref = return &quot;blablabla&quot;<br>
refFst ref = fst `fmap` readRef ref<br>
test = do<br>
   a &lt;- newRef &quot;x&quot;<br>
   b &lt;- newRef 1<br>
   c &lt;- newRef (&#39;z&#39;, Just 0)<br>
   -- no performLocalGC required<br>
   x &lt;- needRef a<br>
   y &lt;- needRef b<br>
   z &lt;- needRef c<br>
   u &lt;- refMaybe y &quot;t&quot; a -- note that it wouldn&#39;t actually read &quot;a&quot;,<br>
                         -- but it won&#39;t be known until runtime.<br>
   w &lt;- refIgnore b<br>
   v &lt;- refFst c<br>
   return (x, y, z)<br>
<br>
<br>
<br>
On Wed, Jan 6, 2010 at 10:28 PM, Edward Kmett &lt;<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>&gt; wrote:<br>
I don&#39;t believe you can get quite the semantics you want. However, you can get reasonably close, by building a manual store and backtracking.<br>
<br>
{-# LANGUAGE Rank2Types #-}<br>
-- lets define an Oracle that tracks whether or not you might need the reference, by backtracking.<br>
module Oracle<br>
  ( Oracle, Ref<br>
  , newRef, readRef, writeRef, modifyRef, needRef<br>
  ) where<br>
<br>
import Control.Applicative<br>
import Control.Arrow (first)<br>
import Control.Monad<br>
import Data.IntMap (IntMap)<br>
import qualified Data.IntMap as M<br>
import Unsafe.Coerce (unsafeCoerce)<br>
import GHC.Prim (Any)<br>
<br>
-- we need to track our own worlds, otherwise we&#39;d have to build over ST, change optimistically, and track how to backtrack the state of the Store. Much uglier.<br>
-- values are stored as &#39;Any&#39;s for safety, see GHC.Prim for a discussion on the hazards of risking the storage of function types using unsafeCoerce as anything else.<br>
data World s = World { store :: !(IntMap Any), hwm :: !Int }<br>
<br>
-- references into our store<br>
newtype Ref s a = Ref Int deriving (Eq)<br>
<br>
-- our monad that can &#39;see the future&#39; ~ StateT (World s) []newtype Oracle s a = Oracle { unOracle :: World s -&gt; [(a, World s)] }<br>
<br>
-- we rely on the fact that the list is always non-empty for any oracle you can run. we are only allowed to backtrack if we thought we wouldn&#39;t need the reference, and wound up needing it, so head will always succeed.<br>

runOracle :: (forall s. Oracle s a) -&gt; a<br>
runOracle f = fst $ head $ unOracle f $ World M.empty 1<br>
<br>
<br>
instance Monad (Oracle s) where<br>
  return a = Oracle $ \w -&gt; [(a,w)]<br>
  Oracle m &gt;&gt;= k = Oracle $ \s -&gt; do<br>
      (a,s&#39;) &lt;- m s<br>
      unOracle (k a) s&#39;<br>
<br>
-- note: you cannot safely define fail here without risking a crash in runOracle<br>
-- Similarly, we&#39;re not a MonadPlus instance because we always want to succeed eventually.<br>
<br>
instance Functor (Oracle s) where<br>
  fmap f (Oracle g) = Oracle $ \w -&gt; first f &lt;$&gt; g w<br>
<br>
instance Applicative (Oracle s) where<br>
  pure = return<br>
  (&lt;*&gt;) = ap<br>
<br>
-- new ref allocates a fresh slot and inserts the value into the store. the type level brand &#39;s&#39; keeps us safe, and we don&#39;t export the Ref constructor.<br>
newRef :: a -&gt; Oracle s (Ref s a)<br>
newRef a = Oracle $ \(World w t) -&gt;<br>
  [(Ref t, World (M.insert t (unsafeCoerce a) w) (t + 1))]<br>
<br>
-- readRef is the only thing that ever backtracks, if we try to read a reference we claimed we wouldn&#39;t need, then we backtrack to when we decided we didn&#39;t need the reference, and continue with its value.<br>
readRef :: Ref s a -&gt; Oracle s a<br>
readRef (Ref slot) = Oracle $ \world -&gt;<br>
  maybe [] (\a -&gt; [(unsafeCoerce a, world)]) $ M.lookup slot (store world)<br>
<br>
-- note, writeRef dfoesn&#39;t &#39;need&#39; the ref&#39;s current value, so needRef will report False if you writeRef before you read it after this.<br>
writeRef :: a -&gt; Ref s a -&gt; Oracle s a<br>
writeRef a (Ref slot) = Oracle $ \world -&gt;<br>
      [(a, world { store = M.insert slot (unsafeCoerce a) $ store world })]<br>
<br>
{-<br>
-- alternate writeRef where writing &#39;needs&#39; the ref.<br>
writeRef :: a -&gt; Ref s a -&gt; Oracle s a<br>
writeRef a (Ref slot) = Oracle $ \World store v -&gt; do<br>
  (Just _, store&#39;) &lt;- return $ updateLookupWithKey replace slot store<br>
  [(a, World store&#39; v)]<br>
 where<br>
  replace _ _ = Just (unsafeCoerce a)<br>
-}<br>
<br>
-- modifying a reference of course needs its current value.<br>
modifyRef :: (a -&gt; a) -&gt; Ref s a -&gt; Oracle s a<br>
modifyRef f r = do<br>
  a &lt;- readRef r<br>
  writeRef (f a) r<br>
<br>
-- needRef tries to continue executing the world without the element in the store in question. if that fails, then we&#39;ll backtrack to here, and try again with the original world, and report that the element was in fact needed.<br>

needRef :: Ref s a -&gt; Oracle s Bool<br>
needRef (Ref slot) = Oracle $ \world -&gt;<br>
  [ (False, world { store = M.delete slot $ store world })<br>
  , (True, world)<br>
  ]<br>
<br>
-- test case:<br>
refMaybe b dflt ref = if b then readRef ref else return dflt<br>
refIgnore ref = return &quot;blablabla&quot;<br>
refFst ref = fst &lt;$&gt; readRef ref<br>
test = do<br>
   a &lt;- newRef &quot;x&quot;<br>
   b &lt;- newRef 1<br>
   c &lt;- newRef (&#39;z&#39;, Just 0)<br>
   -- no performLocalGC required<br>
   x &lt;- needRef a<br>
   y &lt;- needRef b<br>
   z &lt;- needRef c<br>
   u &lt;- refMaybe y &quot;t&quot; a -- note that it wouldn&#39;t actually read &quot;a&quot;,<br>
                         -- but it won&#39;t be known until runtime.<br>
   w &lt;- refIgnore b<br>
   v &lt;- refFst c<br>
   return (x, y, z)<br>
<br>
-- This will disagree with your desired answer, returning:<br>
<br>
*Oracle&gt; runOracle test<br>
Loading package syb ... linking ... done.<br>
Loading package array-0.2.0.0 ... linking ... done.<br>
Loading package containers-0.2.0.1 ... linking ... done.<br>
(False,False,True)<br>
<br>
rather than (True, False, True), because the oracle is able to see into the future (via backtracking) to see that refMaybe doesn&#39;t use the reference after all.<br>
<br>
This probably won&#39;t suit your needs, but it was a fun little exercise.<br>
<br>
-Edward Kmett<br>
<br>
On Wed, Jan 6, 2010 at 4:05 PM, Miguel Mitrofanov &lt;<a href="mailto:miguelimo38@yandex.ru" target="_blank">miguelimo38@yandex.ru</a>&gt; wrote:<br>
<br>
On 6 Jan 2010, at 23:21, Edward Kmett wrote:<br>
<br>
You probably just want to hold onto weak references for your &#39;isStillNeeded&#39; checks.<br>
<br>
That&#39;s what I do now. But I want to minimize the network traffic, so I want referenced values to be garbage collected as soon as possible - and I couldn&#39;t find anything except System.Mem.performIO to do the job - which is a bit too global for me.<br>

<br>
Otherwise the isStillNeeded check itself will keep you from garbage collecting!<br>
<br>
Not necessary. What I&#39;m imagining is that there is essentially only one way to access the value stored in the reference - with readRef. So, if there isn&#39;t any chance that readRef would be called, the value can be garbage collected; &quot;isStillNeeded&quot; function only needs the reference, not the value.<br>

<br>
Well, yeah, that&#39;s kinda like weak references.<br>
<br>
<br>
<a href="http://cvs.haskell.org/Hugs/pages/libraries/base/System-Mem-Weak.html" target="_blank">http://cvs.haskell.org/Hugs/pages/libraries/base/System-Mem-Weak.html</a><br>
<br>
-Edward Kmett<br>
<br>
On Wed, Jan 6, 2010 at 9:39 AM, Miguel Mitrofanov &lt;<a href="mailto:miguelimo38@yandex.ru" target="_blank">miguelimo38@yandex.ru</a>&gt; wrote:<br>
I&#39;ll take a look at them.<br>
<br>
I want something like this:<br>
<br>
refMaybe b dflt ref = if b then readRef ref else return dflt<br>
refIgnore ref = return &quot;blablabla&quot;<br>
refFst ref =<br>
do<br>
  (v, w) &lt;- readRef ref<br>
  return v<br>
test =<br>
do<br>
  a &lt;- newRef &quot;x&quot;<br>
  b &lt;- newRef 1<br>
  c &lt;- newRef (&#39;z&#39;, Just 0)<br>
  performLocalGC -- if necessary<br>
  x &lt;- isStillNeeded a<br>
  y &lt;- isStillNeeded b<br>
  z &lt;- isStillNeeded c<br>
  u &lt;- refMaybe y &quot;t&quot; a -- note that it wouldn&#39;t actually read &quot;a&quot;,<br>
                        -- but it won&#39;t be known until runtime.<br>
  w &lt;- refIgnore b<br>
  v &lt;- refFst c<br>
  return (x, y, z)<br>
<br>
so that &quot;run test&quot; returns (True, False, True).<br>
<br>
<br>
Dan Doel wrote:<br>
On Wednesday 06 January 2010 8:52:10 am Miguel Mitrofanov wrote:<br>
Is there any kind of &quot;ST&quot; monad that allows to know if some STRef is no<br>
longer needed?<br>
<br>
The problem is, I want to send some data to an external storage over a<br>
network and get it back later, but I don&#39;t want to send unnecessary data.<br>
<br>
I&#39;ve managed to do something like that with weak pointers,<br>
System.Mem.performGC and unsafePerformIO, but it seems to me that invoking<br>
GC every time is an overkill.<br>
<br>
Oh, and I&#39;m ready to trade the purity of runST for that, if necessary.<br>
<br>
You may be able to use something like Oleg&#39;s Lightweight Monadic Regions to get this effect. I suppose it depends somewhat on what qualifies a reference as &quot;no longer needed&quot;.<br>
<br>
<a href="http://www.cs.rutgers.edu/%7Eccshan/capability/region-io.pdf" target="_blank">http://www.cs.rutgers.edu/~ccshan/capability/region-io.pdf</a><br>
<br>
I&#39;m not aware of anything out-of-the-box that does what you want, though.<br>
<br>
-- Dan<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
<br>
</div></div></blockquote></div><br>