Stability | experimental |
---|---|
Maintainer | conal@conal.net |
Data.Unamb
Contents
Description
Unambiguous choice
For non-flat types (where values may be partially defined, rather than necessarily bottom or fully defined) and information merging, see the lub package, http://haskell.org/haskellwiki/Lub.
See unamb.cabal for the list of contributors.
- unamb :: a -> a -> a
- unamb' :: a -> a -> a
- unambs :: [a] -> a
- assuming :: Bool -> a -> a
- asAgree :: Eq a => a -> a -> a
- parCommute :: (a -> a -> b) -> a -> a -> b
- parCommuteShortCircuit :: (a -> a -> b) -> a -> a -> b
- parAnnihilator :: Eq a => (a -> a -> a) -> a -> a -> a -> a
- parIdentity :: Eq a => (a -> a -> a) -> a -> a -> a -> a
- parAnnihilatorIdentity :: Eq a => (a -> a -> a) -> a -> a -> a -> a -> a
- por :: Bool -> Bool -> Bool
- pand :: Bool -> Bool -> Bool
- pmin :: (Ord a, Bounded a) => a -> a -> a
- pmax :: (Ord a, Bounded a) => a -> a -> a
- pmult :: Num a => a -> a -> a
- amb :: a -> a -> IO a
- amb' :: a -> a -> IO a
- race :: IO a -> IO a -> IO a
- data BothBottom
Purely functional unambiguous choice
unamb :: a -> a -> a
Unambiguous choice operator. Equivalent to the ambiguous choice
operator, but with arguments restricted to be equal where not bottom,
so that the choice doesn't matter. See also amb
.
If anything kills unamb while it is evaluating (like nested unambs), it can be retried later but, unlike most functions, work may be lost.
unamb' :: a -> a -> a
For use when we already know that neither argument is already evaluated
Some useful special applications of unamb
parCommute :: (a -> a -> b) -> a -> a -> b
Turn a binary commutative operation into one that tries both orders in
parallel. Useful when there are special cases that don't require
evaluating both arguments. For non-flat types and information merging,
see parCommute
in the lub
package.
parCommuteShortCircuit :: (a -> a -> b) -> a -> a -> b
Turn a binary commutative operation into one that may try both orders.
unlike parCommute, if one argument is already evaluated, the function is
tried *only* with that as its first argument and not in both orders. When
in doubt, use parCommute
.
parAnnihilator :: Eq a => (a -> a -> a) -> a -> a -> a -> a
parIdentity :: Eq a => (a -> a -> a) -> a -> a -> a -> a
parAnnihilatorIdentity :: Eq a => (a -> a -> a) -> a -> a -> a -> a -> a
pmin :: (Ord a, Bounded a) => a -> a -> a
Parallel min with minBound short-circuit and maxBound identity
pmax :: (Ord a, Bounded a) => a -> a -> a
Parallel max with maxBound short-circuit and minBound identity
Some related imperative tools
Race two actions against each other in separate threads, and pick
whichever finishes first. See also amb
.