both: Like Maybe, but with a different Monoid instance.

[ data, library, mit ] [ Propose Tags ]

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




Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,
Dependencies base (>=4.7 && <5.0), semigroups (>=0.16), zero (>=0.1 && <0.2) [details]
License MIT
Author Michael Walker
Revised Revision 1 made by barrucadu at 2019-05-12T20:42:34Z
Category Data
Home page
Bug tracker
Source repo head: git clone
this: git clone
Uploaded by barrucadu at 2016-05-26T11:10:13Z
Distributions NixOS:
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2494 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-05-26 [all 1 reports]