Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active July 28, 2017 17:49
Show Gist options
  • Save deque-blog/713a206564c69f57fe5379618e2d5960 to your computer and use it in GitHub Desktop.
Save deque-blog/713a206564c69f57fe5379618e2d5960 to your computer and use it in GitHub Desktop.
taking : Nat -> Transducer acc s (Nat, s) a a
taking n = statefulTransducer n takeImpl
where
takeImpl next (Z, acc) a = pure (Done (Z, acc))
takeImpl next (n, acc) a = withState (pred n) <$> next acc a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment