Skip to content

Instantly share code, notes, and snippets.

@theqp

theqp/After.hs Secret

Created October 7, 2021 16:03
Show Gist options
  • Save theqp/bf5061b6e9202b70a97133888e770550 to your computer and use it in GitHub Desktop.
Save theqp/bf5061b6e9202b70a97133888e770550 to your computer and use it in GitHub Desktop.
class Fold a where
fold :: a
instance Fold (b -> (a -> b) -> Maybe a -> b) where
fold nothing just = \case
Nothing -> nothing
Just a -> just a
instance Fold ((a -> c) -> (b -> c) -> Either a b -> c) where
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