Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active July 16, 2017 19:21
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/e6d3f14f2541785b92356781c6c83216 to your computer and use it in GitHub Desktop.
Save deque-blog/e6d3f14f2541785b92356781c6c83216 to your computer and use it in GitHub Desktop.
runSteps : (Foldable t) => Step st acc elem -> acc -> t elem -> State st (Status acc)
runSteps step acc elems =
foldr stepImpl (pure . id) elems (Continue acc) -- Using continuation passing style
where
stepImpl _ nextIteration (Done acc) = pure (Done acc)
stepImpl e nextIteration (Continue acc) = step acc e >>= nextIteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment