Permalink
Browse files

unambs; PatternMatchFail

darcs-hash:20090120200453-fb517-4466e441fda877e0172b8e392589276c3e4628d4.gz
  • Loading branch information...
1 parent 9a01943 commit 3bd634943041ef908ab2e870e58cf06b495ceb03 @conal conal committed Jan 20, 2009
Showing with 14 additions and 7 deletions.
  1. +8 −3 src/Data/Unamb.hs
  2. +1 −1 unamb.cabal
  3. +5 −3 wikipage.tw
View
@@ -23,7 +23,7 @@ module Data.Unamb
-- * Purely functional unambiguous choice
unamb
-- * Some useful special applications of 'unamb'
- , assuming, asAgree
+ , unambs, assuming, asAgree
, parCommute, parIdentity, parAnnihilator
, por, pand, pmin, pmax, pmult
-- * Some related imperative tools
@@ -46,6 +46,10 @@ unamb = (fmap.fmap) unsafePerformIO amb
-- a `unamb` b = unsafePerformIO (a `amb` b)
+-- | n-ary 'unamb'
+unambs :: [a] -> a
+unambs = foldr unamb undefined
+
-- | Ambiguous choice operator. Yield either value. Evaluates in
-- separate threads and picks whichever finishes first. See also
-- 'unamb' and 'race'.
@@ -110,8 +114,9 @@ race a b = block $ do
-- also.
putCatch :: IO a -> MVar a -> IO ()
putCatch act v = (act >>= putMVar v) `catches`
- [ Handler $ \ (ErrorCall _) -> return ()
- , Handler $ \ BlockedOnDeadMVar -> return ()
+ [ Handler $ \ ErrorCall {} -> return ()
+ , Handler $ \ BlockedOnDeadMVar {} -> return ()
+ , Handler $ \ PatternMatchFail {} -> return ()
-- This next handler hides bogus black holes, which show up as
-- "<<loop>>" messages. I'd rather eliminate the problem than hide it.
-- , Handler $ \ NonTermination -> return ()
View
@@ -1,5 +1,5 @@
Name: unamb
-Version: 0.1.8
+Version: 0.1.9
Cabal-Version: >= 1.2
Synopsis: Unambiguous choice
Category: Concurrency, Data, Other
View
@@ -21,10 +21,12 @@ Besides this wiki page, here are more ways to find out about unamb:
<!-- Please leave comments at the [[Talk:unamb|Talk page]]. -->
See also the [[lub]] package, which extends unamb's usefulness with non-flat types.
+== Issues ==
+
As of version 0.1.1, unamb requires ghc 6.10 or better.
As of version 0.1.6, unamb correctly handles recursive termination of sub-efforts and automatic restarting, but only with the GHC RTS fixes that first appeared (stably, by my testing) in GHC HEAD version 6.11.20090115.
The problems and solution can be found in a few places:
-* Email thread: [http://n2.nabble.com/problem-with-unamb----doesn%27t-kill-enough-threads-tt1674917.html problem with unamb -- doesn't kill enough threads]
-* Blog post: [http://conal.net/blog/posts/smarter-termination-for-thread-racing/ Smarter termination for thread racing]
-* Email thread: [http://n2.nabble.com/Re%3A-black-hole-detection-and-concurrency-td2016290.htm Black hole detection and concurrency]
+* Email thread: ''[http://n2.nabble.com/problem-with-unamb----doesn%27t-kill-enough-threads-tt1674917.html Problem with unamb -- doesn't kill enough threads]''
+* Blog post: ''[http://conal.net/blog/posts/smarter-termination-for-thread-racing/ Smarter termination for thread racing]''
+* Email thread: ''[http://n2.nabble.com/Re%3A-black-hole-detection-and-concurrency-td2016290.htm Black hole detection and concurrency]''

0 comments on commit 3bd6349

Please sign in to comment.