Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created December 23, 2016 21:40
Show Gist options
  • Save deque-blog/72eb67aa745b4a91a368945eafb35f56 to your computer and use it in GitHub Desktop.
Save deque-blog/72eb67aa745b4a91a368945eafb35f56 to your computer and use it in GitHub Desktop.
treeWalkM :: Tree a -> [a]
treeWalkM EmptyTree = []
treeWalkM (Tree root) = treeWalkM' root
treeWalkM' :: Node a -> [a]
treeWalkM' n = runCont (loop n) id
where
loop (Node v cs) = do
rs <- mapM loop cs
return (v : concat rs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment