agreeing: Idiomatic data structure for agreement

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

Please see the README on GitHub at https://github.com/jcranch/agreeing#readme


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.2.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5) [details]
License BSD-3-Clause
Copyright 2023 James Cranch
Author James Cranch
Maintainer j.d.cranch@sheffield.ac.uk
Category Data
Home page https://github.com/jcranch/agreement#readme
Bug tracker https://github.com/jcranch/agreement/issues
Source repo head: git clone https://github.com/jcranch/agreement
Uploaded by jcranch at 2023-11-06T00:38:11Z
Distributions LTSHaskell:0.2.2.0, NixOS:0.2.2.0, Stackage:0.2.2.0
Downloads 239 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 2023-11-06 [all 1 reports]

Readme for agreeing-0.2.2.0

[back to package description]

agreeing

A simple data structure helping us ask questions of the following sort: "does all this data have the same /BLANK/ and if so what is it?"

For example:

    doTheseHaveTheSameLength :: [String] -> String
    doTheseHaveTheSameLength l = case foldMap (Somebody . length) of
      Somebody n -> "They all have length " <> show n
      Nobody     -> "The lengths differ"
      Anybody    -> "You didn't give me any strings"

This can of course be done with Maybe (Maybe x) instead, but doing so runs the risk of getting confused: which is Nothing and which is Just Nothing?