Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created January 21, 2017 15:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
import Control.Monad.Cont
cataCps :: (Traversable f) => (f a -> a) -> Fix f -> a
cataCps algebra expr = runCont (recur algebra expr) id
recur :: (Traversable f) => (f a -> a) -> Fix f -> Cont a a
recur algebra (Fix expr) = do
sub <- sequence $ fmap (recur algebra) expr
return (algebra sub)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment