Skip to content

Instantly share code, notes, and snippets.

@danieldk
Created March 1, 2011 12:40
Show Gist options
  • Save danieldk/849066 to your computer and use it in GitHub Desktop.
Save danieldk/849066 to your computer and use it in GitHub Desktop.
Fold for rose tree zippers
tzFold :: (a -> TreePos Full b -> a) -> a -> TreePos Full b -> a
tzFold f acc t =
foldSiblings $ foldChildren $ f acc t
where
foldChildren acc' =
case firstChild t of
Just c -> tzFold f acc' c
Nothing -> acc'
foldSiblings acc' =
case next t of
Just s -> tzFold f acc' s
Nothing -> acc'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment