packages feed

unamb 0.2.3 → 0.2.4

raw patch · 2 files changed

+34/−4 lines, 2 filesdep −tag-bitsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: tag-bits

API changes (from Hackage documentation)

- Data.Unamb: asAgree :: (Eq a) => a -> a -> a
+ Data.Unamb: asAgree :: Eq a => a -> a -> a
- Data.Unamb: parAnnihilator :: (Eq a) => (a -> a -> a) -> a -> (a -> a -> a)
+ Data.Unamb: parAnnihilator :: Eq a => (a -> a -> a) -> a -> (a -> a -> a)
- Data.Unamb: parAnnihilatorIdentity :: (Eq a) => (a -> a -> a) -> a -> a -> a -> a -> a
+ Data.Unamb: parAnnihilatorIdentity :: Eq a => (a -> a -> a) -> a -> a -> a -> a -> a
- Data.Unamb: parIdentity :: (Eq a) => (a -> a -> a) -> a -> a -> a -> a
+ Data.Unamb: parIdentity :: Eq a => (a -> a -> a) -> a -> a -> a -> a
- Data.Unamb: pmult :: (Num a) => a -> a -> a
+ Data.Unamb: pmult :: Num a => a -> a -> a

Files

src/Data/Unamb.hs view
@@ -41,10 +41,16 @@ import Control.Concurrent import Control.Exception import Data.Typeable-import Data.TagBits (unsafeIsEvaluated) +-- Drop the unsafeIsEvaluated optimization for now.  See comments below.++-- import Data.TagBits (unsafeIsEvaluated) -- import Data.IsEvaluated +-- Temporary def until I know how to detect and handle evaluated-as-bottom values.+unsafeIsEvaluated :: a -> Bool+unsafeIsEvaluated = const False+ -- | Use a particular exception as our representation for waiting forever. data BothBottom = BothBottom deriving(Show,Typeable) @@ -68,6 +74,18 @@     | otherwise = unamb' a b {-# INLINE unamb #-} +-- I want something like the following:++-- unamb a b+--     | unsafeIsEvaluated a = if isBottom a then b else a+--     | unsafeIsEvaluated b = if isBottom b then a else b+--     | otherwise = unamb' a b++-- where isBottom assumes that its argument is recognizably evaluated+-- (unsafeIsEvaluated yields True).  What does an evaluated bottom values+-- look like in the RTS?++ -- | For use when we already know that neither argument is already evaluated unamb' :: a -> a -> a unamb' = (fmap.fmap) restartingUnsafePerformIO amb'@@ -128,11 +146,15 @@  -- | n-ary 'unamb' unambs :: [a] -> a+unambs = foldr unamb undefined++{- unambs []  = undefined unambs xs  = foldr1 unamb' xs `unamb'` foldr findEvaluated undefined xs     where         findEvaluated a b | unsafeIsEvaluated a = a                           | otherwise = b+-}  -- | Ambiguous choice operator.  Yield either value.  Evaluates in -- separate threads and picks whichever finishes first.  See also@@ -239,6 +261,9 @@ a `asAgree` b = assuming (a == b) a {-# INLINE asAgree #-} +-- Note: asAgree == flatGlb (from Data.Glb in lub package).+-- Examine uses of asAgree,u and consider whether glb is a better fit.+ {--------------------------------------------------------------------     Some useful special applications of 'unamb' --------------------------------------------------------------------}@@ -345,6 +370,9 @@ {-  -- Examples:++undefined `unamb` 3 :: Int+3 `unamb` undefined :: Int  undefined `por` True True `por` undefined
unamb.cabal view
@@ -1,5 +1,5 @@ Name:                unamb-Version:             0.2.3+Version:             0.2.4 Cabal-Version:       >= 1.2 Synopsis:            Unambiguous choice Category:            Concurrency, Data, Other@@ -32,8 +32,10 @@ Library   hs-Source-Dirs:      src   Extensions:-  Build-Depends:       base >= 4 && < 5,-                       tag-bits >= 0.1 && < 0.2+  Build-Depends:       base >= 4 && < 5++--                     , tag-bits >= 0.1.1 && < 0.2+   Exposed-Modules:                             Data.Unamb   ghc-options:         -Wall