Skip to content

Instantly share code, notes, and snippets.

@ddellacosta
Created October 27, 2018 18:55
Show Gist options
  • Save ddellacosta/85ddab8a506fa3eeddbc7b1c79877e8b to your computer and use it in GitHub Desktop.
Save ddellacosta/85ddab8a506fa3eeddbc7b1c79877e8b to your computer and use it in GitHub Desktop.
Bool + Product type with associativity?
data Find a = NotFound a | Found a
deriving (Eq, Show)
instance (Semigroup a) => Semigroup (Find a) where
NotFound a <> NotFound b = NotFound (a <> b)
NotFound a <> Found b = Found (a <> b)
Found a <> NotFound b = Found (a <> b)
Found a <> Found b = Found (a <> b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment