iteratee takeWhile - coule functions for analogy with lists

John Lato jwlato at gmail.com
Tue Sep 6 14:55:18 BST 2011


These seem sensible enough.  I've pushed them to the repo.

I will make a hackage release soon, which will include the eneeCheck*
functions.  Still not convinced unfoldConvStreamCheck is correct...

John

On Tue, Sep 6, 2011 at 5:35 AM, Michael Baikov <manpacket at gmail.com> wrote:
> I think this will fit nicely in Data.Iteratee.ListLike. This function
> can cause some troubles when used improperly, but it's no more
> harmfull than stream2stream or stream2list which we already have.
>
> -- | Take all elements while predicate is true. Make sure that it will
> encounter element where predicate is
> -- false or protect your iteratee with enumWith.
>
> -- | Takes an element predicate and returns the (possibly empty)
> prefix of the stream. All characters
> -- in the string will satisfy the character predicate. If the stream
> is not terminated, the first character of the
> -- remaining stream will not satisfy the predicate.
> -- The analogue of @List.takeWhile@, see also @break@ and @takeWhileE@
> takeWhile :: (ListLike s el, Monad m) => (el -> Bool) -> Iteratee s m s
> takeWhile = break . not
>
> -- |Takes an element predicate and an iteratee, running the iteratee
> -- on all elements of the stream while the predicate is met. This is
> preferred to
> -- @takeWhile at .
> takeWhileE
>  :: (Monad m, LL.ListLike s el, NullPoint s)
>  => (el -> Bool)
>  -> Enumeratee s s m a
> takeWhileE = breakE . not
>
> _______________________________________________
> Iteratee mailing list
> Iteratee at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/iteratee
>



More information about the Iteratee mailing list