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

[ data, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

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

Modules

[Index]

Downloads

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

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.1.1, 0.1.1.2
Dependencies base (>=4.7 && <5.0), semigroups (>=0.16), zero (>=0.1 && <0.2) [details]
License MIT
Author Michael Walker
Maintainer mike@barrucadu.co.uk
Revised Revision 1 made by barrucadu at 2019-05-12T20:42:34Z
Category Data
Home page https://github.com/barrucadu/both
Bug tracker https://github.com/barrucadu/both/issues
Source repo head: git clone https://github.com/barrucadu/both.git
this: git clone https://github.com/barrucadu/both.git(tag 0.1.1.0)
Uploaded by barrucadu at 2016-05-26T11:10:13Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2751 total (13 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]