Skip to content

Instantly share code, notes, and snippets.

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