strongweak-0.3.0: Convert between strong and weak representations of types
Safe HaskellSafe-Inferred
LanguageHaskell2010

Strongweak

Synopsis

Instance design

We identify two distinct types of instances for strongweak classes:

  • invariant handler: removes or adds an invariant
  • decomposer: transforms through some structural type

In order to provide good behaviour and composability, we don't mix both in a single instance. The decomposers are really just convenience to ease instance derivation. In general, decomposers will have a recursive context, and invariant handlers won't.

An example is NonEmpty a. We could weaken this to [a], but also to [Weaken a]. However, the latter would mean decomposing and removing an invariant simultaneously. It would be two separate strengthens in one instance. And now, your a must be in the strongweak ecosystem, which isn't necessarily what you want - indeed, it appears this sort of design would require a Weaken a = a, weaken = id overlapping instance, which I do not want. On the other hand, [a] does weaken to [Weaken a], because there are no invariants present to remove, so decomposing is all the user could hope to do.

Re-exports