both

Like Maybe, but with a different Monoid instance. https://github.com/barrucadu/both

Version on this page:0.1.1.0
LTS Haskell 15.15:0.1.1.1
Stackage Nightly 2020-06-01:0.1.1.1
Latest on Hackage:0.1.1.1

See all snapshots both appears in

MIT licensed by Michael Walker
Maintained by [email protected]

Module documentation for 0.1.1.0

This version can be pinned in stack with:[email protected]:fe3081aa2a99871b3b3cc459227f9741b64c724478d212502f4646f5ec984aeb,1662

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
Depends on 3 packages(full list with versions):