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] [Quick Jump]

Downloads

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
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.2)
Uploaded by barrucadu at 2021-08-15T12:20:12Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2739 total (19 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-08-15 [all 1 reports]