-
-
Save dustinlacewell/7c00fe33d757ffa447228707836e9b90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
• 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)’ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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