
Data.Unamb  Stability  experimental  Maintainer  conal@conal.net 





Description 
Unambiguous choice
For nonflat 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.


Synopsis 




Purely functional unambiguous choice



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.


Some useful special applications of unamb



nary unamb



Yield a value if a condition is true. Otherwise undefined.



The value of agreeing values (or undefined/bottom)


parCommute :: (a > a > b) > a > a > b  Source 

Turn a binary commutative operation into that tries both orders in
parallel. Useful when there are special cases that don't require
evaluating both arguments. For nonflat types and information merging,
see parCommute in the lub package.


parIdentity :: Eq a => (a > a > a) > a > a > a > a  Source 

Binary operation with left & right identity element. For instance, (*) & 1,
(&&) & True, () & False, min & maxBound, max & minBound.
Tests either argument as identity, in parallel.


parAnnihilator :: Eq a => (a > a > a) > a > a > a > a  Source 

Binary operation with annihilator element. For instance, (*) & 0,
(&&) & False, () & True, min & minBound, max & maxBound.
Tests either argument as annihilator, in parallel.



Parallel or



Parallel and



Parallel min with minBound shortcircuit



Parallel max with maxBound shortcircuit



Parallel multiplication with 0 shortcircuit


Some related imperative tools



Ambiguous choice operator. Yield either value. Evaluates in
separate threads and picks whichever finishes first. See also
unamb and race.



Race two actions against each other in separate threads, and pick
whichever finishes first. See also amb.


Produced by Haddock version 2.4.2 