lub 0.0.1 → 0.0.2
raw patch · 2 files changed
+11/−21 lines, 2 filesdep ~unamb
Dependency ranges changed: unamb
Files
- lub.cabal +2/−2
- src/Data/Lub.hs +9/−19
lub.cabal view
@@ -1,5 +1,5 @@ Name: lub-Version: 0.0.1+Version: 0.0.2 Cabal-Version: >= 1.2 Synopsis: least upper bounds -- information merging Category: Concurrency, Data, Other@@ -26,7 +26,7 @@ Library hs-Source-Dirs: src Extensions:- Build-Depends: base, unamb >= 0.1.0+ Build-Depends: base, unamb >= 0.1.2 Exposed-Modules: Data.Repr Data.Lub
src/Data/Lub.hs view
@@ -11,6 +11,8 @@ -- -- Compute least upper bound ('lub') of two values, with respect to -- information content. I.e., merge the information available in each.+-- For flat types (in which all values are either bottom or fully+-- defined), 'lub' is equivalent to 'unamb'. ---------------------------------------------------------------------- module Data.Lub@@ -18,12 +20,13 @@ -- * Least upper bounds HasLub(..), bottom, flatLub -- * Some useful special applications of 'lub'- , parCommute, por, pand, ptimes+ , parCommute, pand, por, ptimes ) where import Control.Applicative (liftA2) -import Data.Unamb+import Data.Unamb hiding (parCommute)+import qualified Data.Unamb as Unamb import Data.Repr @@ -42,7 +45,6 @@ -- @ -- instance HasLub Integer where lub = flatLub -- @- flatLub :: a -> a -> a flatLub = unamb @@ -133,24 +135,13 @@ -} --{--------------------------------------------------------------------- Some useful special applications of 'unamb'---------------------------------------------------------------------}- -- | Turn a binary commutative operation into that tries both orders in -- parallel, 'lub'-merging the results. Useful when there are special -- cases that don't require evaluating both arguments.-parCommute :: HasLub a => (a -> a -> a) -> (a -> a -> a)-parCommute op a b = (a `op` b) `lub` (b `op` a)---- | Parallel or-por :: Bool -> Bool -> Bool-por = parCommute (||)---- | Parallel and-pand :: Bool -> Bool -> Bool-pand = parCommute (&&)+-- +-- Similar to 'Unamb.parCommute', but uses 'lub' instead of 'unamb'.+parCommute :: HasLub b => (a -> a -> b) -> (a -> a -> b)+parCommute op x y = (x `op` y) `lub` (y `op` x) -- | Multiplication optimized for either argument being zero or one, where -- the other might be expensive/delayed.@@ -183,4 +174,3 @@ bottom `ptimes` 0 :: Integer -}-