Skip to content

Instantly share code, notes, and snippets.

@theqp

theqp/Before.hs Secret

Created October 7, 2021 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theqp/9a450ffdc6dbb3de77a275c8debfb1eb to your computer and use it in GitHub Desktop.
Save theqp/9a450ffdc6dbb3de77a275c8debfb1eb to your computer and use it in GitHub Desktop.
fold :: b -> (a -> b) -> Maybe a -> b
fold nothing just = \case
Nothing -> nothing
Just a -> just a
fold :: (a -> c) -> (b -> c) -> Either a b -> c
fold l r = \case
Left a -> l a
Right b -> r b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment