packages feed

pipes-concurrency 2.0.5 → 2.0.6

raw patch · 2 files changed

+27/−5 lines, 2 filesdep +contravariantdep +voiddep ~pipesPVP ok

version bump matches the API change (PVP)

Dependencies added: contravariant, void

Dependency ranges changed: pipes

API changes (from Hackage documentation)

+ Pipes.Concurrent: instance Data.Functor.Contravariant.Contravariant Pipes.Concurrent.Output
+ Pipes.Concurrent: instance Data.Functor.Contravariant.Divisible.Decidable Pipes.Concurrent.Output
+ Pipes.Concurrent: instance Data.Functor.Contravariant.Divisible.Divisible Pipes.Concurrent.Output

Files

pipes-concurrency.cabal view
@@ -1,5 +1,5 @@ Name: pipes-concurrency-Version: 2.0.5+Version: 2.0.6 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3@@ -31,9 +31,11 @@ Library     Hs-Source-Dirs: src     Build-Depends:-        base         >= 4     && < 5  ,-        pipes        >= 4.0   && < 4.2,-        stm          >= 2.4.3 && < 2.5+        base          >= 4     && < 5  ,+        contravariant >= 1.3.3 && < 1.5,+        pipes         >= 4.0   && < 4.3,+        stm           >= 2.4.3 && < 2.5,+        void          >= 0.6   && < 1     Exposed-Modules:         Pipes.Concurrent,         Pipes.Concurrent.Tutorial@@ -45,7 +47,7 @@     HS-Source-Dirs: tests .     Build-Depends:         base              >= 4     && < 5  ,-        pipes             >= 4.0.0 && < 4.2,+        pipes             >= 4.0.0 && < 4.3,         pipes-concurrency >= 2.0.0 && < 2.1,         stm               >= 2.4.3 && < 2.5,         async             >= 2.0   && < 2.2
src/Pipes/Concurrent.hs view
@@ -35,7 +35,11 @@ import qualified Control.Concurrent.STM as S import Control.Exception (bracket) import Control.Monad (when,void, MonadPlus(..))+import Data.Functor.Contravariant (Contravariant(contramap))+import Data.Functor.Contravariant.Divisible (+    Divisible(divide, conquer), Decidable(lose, choose)) import Data.Monoid (Monoid(mempty, mappend))+import Data.Void (absurd) import Pipes (MonadIO(liftIO), yield, await, Producer', Consumer') import System.Mem (performGC) @@ -87,6 +91,22 @@ instance Monoid (Output a) where     mempty  = Output (\_ -> return False)     mappend i1 i2 = Output (\a -> (||) <$> send i1 a <*> send i2 a)++-- | This instance is useful for creating new tagged address, similar to elm's+-- Signal.forwardTo. In fact elm's forwardTo is just 'flip contramap'+instance Contravariant Output where+    contramap f (Output a) = Output (a . f)++instance Divisible Output where+    conquer = Output (\_ -> return False)+    divide f i1 i2 = Output $ \a -> case f a of+        (b, c) -> (||) <$> send i1 b <*> send i2 c++instance Decidable Output where+    lose f = Output (absurd . f)+    choose f i1 i2 = Output $ \a -> case f a of+        Left b -> send i1 b+        Right c -> send i2 c  {-| Convert an 'Output' to a 'Pipes.Consumer'