quiver 1.0.0 → 1.0.1
raw patch · 4 files changed
+37/−15 lines, 4 filesdep ~transformers
Dependency ranges changed: transformers
Files
- quiver.cabal +2/−2
- src/Control/Quiver.lhs +1/−1
- src/Control/Quiver/Internal.lhs +7/−6
- src/Control/Quiver/SP.lhs +27/−6
quiver.cabal view
@@ -1,5 +1,5 @@ name: quiver-version: 1.0.0+version: 1.0.1 synopsis: Quiver finite stream processing library homepage: https://github.com/zadarnowski/quiver category: Control@@ -34,7 +34,7 @@ source-repository this type: git location: https://github.com/zadarnowski/quiver.git- tag: 1.0.0+ tag: 1.0.1 library hs-source-dirs: src
src/Control/Quiver.lhs view
@@ -19,7 +19,7 @@ > -- Defined below: > fetch, fetch_, > emit, emit_,-> qlift, qhoist,+> qlift, qhoist, qembed, > qpure, qid, qconcat, > runEffect, > (>>->), (>->>), (>&>),
src/Control/Quiver/Internal.lhs view
@@ -31,7 +31,7 @@ > P (..), Producer, Consumer, Effect, > consume, produce, enclose, deliver, > decouple, deplete,-> qlift, qhoist, qembed+> qlift, qhoist, qembed, > ) where > import Control.Monad.IO.Class@@ -227,14 +227,14 @@ Generalized Transformers ======================== -> -- | @qlift@ lifts the value of a base functor into a stream processor;-> -- same as 'lift' from 'MonadTrans', but relaxing constraint on-> -- the base structure from 'Monad' to 'Functor'.+> -- | Lifts the value of a base functor into a stream processor;+> -- same as 'lift' from 'MonadTrans', but relaxing constraint+> -- on the base structure from 'Monad' to 'Functor'. > qlift :: Functor f => f r -> P a a' b b' f r > qlift = enclose . fmap deliver -> -- | @qhoist@ morphs the value of a base functor into another+> -- | Morphs the value of a base functor into another > -- functor by applying the supplied functor morphism to every > -- 'Enclose' step of a stream processor; same as 'hoist' from > -- 'MFunctor' but relaxing the constraint on the base structure@@ -248,7 +248,8 @@ > loop (Enclose f) = enclose (ff (fmap loop f)) > loop (Deliver r) = deliver r -> -- | @qembed@ ...+> -- | Embeds a monad within another monad transformer;+> -- same as 'embed' from 'MMonad'. > qembed :: Monad g => (forall x . f x -> P a a' b b' g x) -> P a a' b b' f r -> P a a' b b' g r > qembed ff = loop
src/Control/Quiver/SP.lhs view
@@ -24,9 +24,12 @@ > sppure, spid, spconcat, > spfold, spfold', spfoldl, spfoldl', spfoldr, spfoldr', > sptraverse, sptraverse_,+> spevery,+> sprun, > ) where > import Control.Quiver+> import Control.Quiver.Internal > infixr 5 >:> > infixl 1 >>?, >>!@@ -59,11 +62,11 @@ > type SPResult e = Maybe (Maybe e) -> -- | ('Just Nothing') Simple processor result value indicating successful processing of the entire input stream.+> -- | (@'Just' 'Nothing'@) Simple processor result value indicating successful processing of the entire input stream. > pattern SPComplete = Just Nothing -> -- | ('Just (Just e)') Simple processor result value indicating unsuccessful processing of the input stream.+> -- | (@'Just' ('Just' e)'@) Simple processor result value indicating unsuccessful processing of the input stream. > pattern SPFailed e = Just (Just e) @@ -87,9 +90,8 @@ > spincomplete = deliver SPIncomplete > -- | @spfetch@ represents a singleton simple stream processor that-> -- sends the request value @x@ upstream and delivers the-> -- next input value received, or @Nothing@ if the upstream-> -- processor has been depleted.+> -- delivers the next input value received, or @Nothing@ if the+> -- upstream processor has been depleted. > spfetch :: Functor f => SQ a b f (Maybe a) > spfetch = fetch ()@@ -217,8 +219,27 @@ > -- | A processor that consumes every input elemnet using a monadic function. -> sptraverse_ :: Monad m => (a -> m ()) -> SP a b m e+> sptraverse_ :: Monad m => (a -> m ()) -> SConsumer a m e > sptraverse_ k = loop > where > loop = consume () loop' spcomplete > loop' x = qlift (k x) >> loop++> -- | Produces every element of a foldable structure.++> spevery :: Foldable t => t a -> SProducer a f e+> spevery = foldr (>:>) spcomplete+++> -- | Evaluates an 'SEffect', i.e., a simple processor that is both detached+> -- and depleted and hence neither consumes nor produces any input,+> -- returning its delivered value. The base functor must be a monad.++> sprun :: Monad f => forall a b . SQ a b f r -> f r+> sprun p = loop p+> where+> loop (Consume _ _ q) = loop q+> loop (Produce _ _ q) = loop q+> loop (Enclose f) = f >>= loop+> loop (Deliver r) = return r+