Свой Monoid

 avatar
unknown
haskell
2 years ago
304 B
13
Indexable
newtype Maybe' a = Maybe' { getMaybe :: Maybe a }
    deriving (Eq,Show)

instance Monoid a => Monoid (Maybe' a) where
    mempty = Maybe' (Just mempty)
    Maybe' Nothing `mappend` m = m
    m `mappend` Maybe' Nothing = m
    Maybe' (Just m1) `mappend` Maybe' (Just m2) = Maybe' (Just (m1 `mappend` m2))
Editor is loading...