packages feed

list-t 0.2.1 → 0.2.2

raw patch · 3 files changed

+24/−4 lines, 3 files

Files

executables/APITests.hs view
@@ -120,6 +120,10 @@         liftIO $ modifyIORef ref (+1)         return x +test_drop =+  assertEqual [3, 4] =<< do+    toList $ L.drop 2 $ L.fromFoldable [1 .. 4]+      toList :: Monad m => L.ListT m a -> m [a] toList = L.toList
library/ListT.hs view
@@ -24,10 +24,11 @@   -- which happens at the execution.   traverse,   take,+  drop, ) where -import BasePrelude hiding (toList, yield, fold, traverse, head, tail, take, repeat, null, traverse_)+import BasePrelude hiding (toList, yield, fold, traverse, head, tail, take, drop, repeat, null, traverse_) import Control.Monad.Morph import Control.Monad.IO.Class import Control.Monad.Trans.Class@@ -231,7 +232,7 @@ -------------------------  -- |--- A lazy transformation,+-- A transformation, -- which traverses the stream with an action in the inner monad. {-# INLINABLE traverse #-} traverse :: (Monad m, ListMonad (t m), ListTrans t) => (a -> m b) -> t m a -> t m b@@ -241,7 +242,7 @@   maybe mzero return  -- |--- A lazy trasformation, +-- A trasformation,  -- reproducing the behaviour of @Data.List.'Data.List.take'@. {-# INLINABLE take #-} take :: (Monad m, ListMonad (t m), ListTrans t) => Int -> t m a -> t m a@@ -254,3 +255,18 @@           Just (h, t) -> cons h (take (pred n) t)     _ ->       const $ mzero++-- |+-- A trasformation, +-- reproducing the behaviour of @Data.List.'Data.List.drop'@.+{-# INLINABLE drop #-}+drop :: (Monad m, ListMonad (t m), ListTrans t) => Int -> t m a -> t m a+drop =+  \case+    n | n > 0 ->+      lift . uncons >=> maybe mzero (drop (pred n) . snd)+    _ ->+      id+++
list-t.cabal view
@@ -1,7 +1,7 @@ name:   list-t version:-  0.2.1+  0.2.2 synopsis:   ListT done right description: