strongweak: Convert between strong and weak representations of types

[ data, library, mit ] [ Propose Tags ]

Please see README.md.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.4.0, 0.4.1, 0.5.0, 0.6.0, 0.6.1
Change log CHANGELOG.md
Dependencies base (>=4.14 && <5), prettyprinter (>=1.7.1 && <1.8), refined (>=0.6.3 && <0.7), validation (>=1.1.2 && <1.2), vector-sized (>=1.5.0 && <1.6) [details]
License MIT
Author Ben Orchard
Maintainer Ben Orchard <thefirstmuffinman@gmail.com>
Category Data
Home page https://github.com/raehik/strongweak#readme
Bug tracker https://github.com/raehik/strongweak/issues
Source repo head: git clone https://github.com/raehik/strongweak
Uploaded by raehik at 2022-05-16T20:30:32Z
Distributions
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 464 total (36 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for strongweak-0.1.0

[back to package description]

strongweak

Definitions for transforming between types.

  • strong -> weak drops invariants (e.g. going from a bounded to an unbounded numeric type)
  • weak -> Maybe strong introduces invariants

This is not a Convertible library that enumerates transformations between types into a dictionary.

  • A "strong" type has exactly one "weak" representation.
  • Weakening a type is safe.
  • Strengthening a type may fail.

There are generic derivers for generating Strengthen and Weaken instances for arbitrary data types. The Strengthen instances annotate errors extensively, telling you the datatype & record for which strengthening failed - recursively, for nested types.

This is a validation library. We don't fail on the first error -- we attempt to validate every part of a data type, and collate the errors into a list. This happens magically in the generic deriver, but if you're writing your own instances, you may want ApplicativeDo so you can use do notation. So it'll monadic, but actually everything will get checked.