Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell
Created September 12, 2021 03:12
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 dustinlacewell/7c00fe33d757ffa447228707836e9b90 to your computer and use it in GitHub Desktop.
Save dustinlacewell/7c00fe33d757ffa447228707836e9b90 to your computer and use it in GitHub Desktop.
• Could not deduce (Semigroup (Optional a))
arising from the superclasses of an instance declaration
from the context: Monoid a
bound by the instance declaration
at /home/ldlework/src/haskell/hffp/project/app/15/optional.hs:8:10-40
• In the instance declaration for ‘Monoid (Optional a)’
-- Write the Monoid instance for our Maybe type renamed to Optional.
data Optional a =
Nada
| Only a
deriving (Eq, Show)
instance Monoid a => Monoid (Optional a) where
mempty = Nada
mappend Nada Nada = Nada
mappend (Only a) (Only b) = Only (a <> b)
mappend (Only a) Nada = Only a
mappend Nada (Only a) = Only a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment