both

Like Maybe, but with a different Monoid instance.

https://github.com/barrucadu/both

Version on this page:0.1.0.0
LTS Haskell 19.33:0.1.1.2
Stackage Nightly 2022-03-17:0.1.1.2
Latest on Hackage:0.1.1.2

See all snapshots both appears in

MIT licensed by Michael Walker
Maintained by [email protected]
This version can be pinned in stack with:both-0.1.0.0@sha256:590bd7d8a6c3acb3f220533fe46a54533a60456092d16cbe661ef5b913a6cbc7,1570

Module documentation for 0.1.0.0

Depends on 1 package(full list with versions):

The Monoid instance for Maybe behaves like so:

instance Monoid a => Monoid (Maybe a) where
  mappend (Just x) (Just y) = Just $ x <> y
  mappend (Just x) Nothing  = Just x
  mappend Nothing  (Just y) = Just y
  mappend Nothing  Nothing  = Nothing

  mempty = Nothing

Both is a newtype wrapper around Maybe providing this instance:

instance Monoid a => Monoid (Both a) where
  mappend (Just x) (Just y) = Just $ x <> y
  mappend _ _ = Nothing

  mempty = Just mempty