Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active July 28, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/6b077772e86abca5ec91fc132bb56b4f to your computer and use it in GitHub Desktop.
Save deque-blog/6b077772e86abca5ec91fc132bb56b4f to your computer and use it in GitHub Desktop.
takingWhile : (a -> Bool) -> Transducer acc s s a a
takingWhile p = statelessTransducer $
\next, acc, a => do
if p a -- If the element a satisfies the predicate
then next acc a -- * Then forwards it to the rest of the pipe-line
else pure (Done acc) -- * Else trigger an early termination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment