on master help sign in
rename next to uncons
49d4c15Harendra Kumar
examples/mergesort.hs+2−2
@@ -21,11 +21,11 @@ mergeAsync a b = do
21 merge x y
21 merge x y
22
22
23merge a b = do
23merge a b = do
24− x <- A.lift $ A.next a
24+ x <- A.lift $ A.uncons a
25 case x of
25 case x of
26 Nothing -> b
26 Nothing -> b
27 Just (va, ma) -> do
27 Just (va, ma) -> do
28− y <- A.lift $ A.next b
28+ y <- A.lift $ A.uncons b
29 case y of
29 case y of
30 Nothing -> return va A.<> ma
30 Nothing -> return va A.<> ma
31 Just (vb, mb) ->
31 Just (vb, mb) ->
src/Asyncly.hs+1−1
@@ -126,7 +126,7 @@ module Asyncly
126 -- * Running
126 -- * Running
127 , runAsyncly
127 , runAsyncly
128 , toList
128 , toList
129− , next
129+ , uncons
130 , async
130 , async
131
131
132 -- * Monadic Composition (Conjunction)
132 -- * Monadic Composition (Conjunction)
src/Asyncly/AsyncT.hs+6−3
@@ -22,7 +22,7 @@ module Asyncly.AsyncT
22 , MonadAsync
22 , MonadAsync
23 , runAsyncly
23 , runAsyncly
24 , toList
24 , toList
25− , next
25+ , uncons
26 , async
26 , async
27
27
28 , take
28 , take
@@ -703,8 +703,11 @@ toList m = (runAsyncT m) Nothing stop yield
703 yield a Nothing = return [a]
703 yield a Nothing = return [a]
704 yield a (Just x) = liftM (a :) (toList x)
704 yield a (Just x) = liftM (a :) (toList x)
705
705
706+-- | Decompose a stream into its head and tail. If the stream is empty, returns
707+-- 'Nothing'. If the stream is non-empty, returns 'Just (a, ma)', where 'a' is
708+-- the head of the stream and 'ma' its tail.
706−next :: MonadAsync m => AsyncT m a -> m (Maybe (a, AsyncT m a))
709+uncons :: MonadAsync m => AsyncT m a -> m (Maybe (a, AsyncT m a))
707−next m = (runAsyncT m) Nothing stop yield
710+uncons m = (runAsyncT m) Nothing stop yield
708
711
709 where
712 where
710
713