Skip to content

Instantly share code, notes, and snippets.

@Synthetica9
Created October 16, 2018 16:14
Show Gist options
  • Select an option

  • Save Synthetica9/2fd591cd4560eed189206e19c8ae3259 to your computer and use it in GitHub Desktop.

Select an option

Save Synthetica9/2fd591cd4560eed189206e19c8ae3259 to your computer and use it in GitHub Desktop.
superCata :: (Functor f, Foldable f) => (r -> r -> r) -> r -> (f r -> Maybe r) -> Fix f -> r
superCata (+) ϵ f = cata algebra where
algebra x = fromMaybe (foldr (+) ϵ x) $ f x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment