on master help sign in
rename next to uncons
commit49d4c157bd2a31e687856a133df749055b387e77 authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 16 Oct 2017, 08:28 (9 years ago) parent6c061c4
3 files changed+9−6
examples/mergesort.hs+2−2 src/Asyncly.hs+1−1 src/Asyncly/AsyncT.hs+6−3
examples/mergesort.hs+2−2
@@ -21,11 +21,11 @@ mergeAsync a b = do
2121 merge x y
2222
2323merge a b = do
24− x <- A.lift $ A.next a
24+ x <- A.lift $ A.uncons a
2525 case x of
2626 Nothing -> b
2727 Just (va, ma) -> do
28− y <- A.lift $ A.next b
28+ y <- A.lift $ A.uncons b
2929 case y of
3030 Nothing -> return va A.<> ma
3131 Just (vb, mb) ->
src/Asyncly.hs+1−1
@@ -126,7 +126,7 @@ module Asyncly
126126 -- * Running
127127 , runAsyncly
128128 , toList
129− , next
129+ , uncons
130130 , async
131131
132132 -- * Monadic Composition (Conjunction)
src/Asyncly/AsyncT.hs+6−3
@@ -22,7 +22,7 @@ module Asyncly.AsyncT
2222 , MonadAsync
2323 , runAsyncly
2424 , toList
25− , next
25+ , uncons
2626 , async
2727
2828 , take
@@ -703,8 +703,11 @@ toList m = (runAsyncT m) Nothing stop yield
703703 yield a Nothing = return [a]
704704 yield a (Just x) = liftM (a :) (toList x)
705705
706−next :: MonadAsync m => AsyncT m a -> m (Maybe (a, AsyncT m a))
707−next m = (runAsyncT m) Nothing stop yield
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.
709+uncons :: MonadAsync m => AsyncT m a -> m (Maybe (a, AsyncT m a))
710+uncons m = (runAsyncT m) Nothing stop yield
708711
709712 where
710713