Copyright | Travis Whitaker 2019 |
---|---|
License | MIT |
Maintainer | pi.boy.travis@gmail.com |
Stability | Provisional |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
See http://programmable.computer/compatible.html for a full exposition and worked examples.
Synopsis
- class Compat a where
- type Pred a :: *
- type CompatConstraint a :: * -> Constraint
- type CompatF a :: * -> *
- migrate :: Pred a -> CompatF a a
- continue :: Proxy a -> Maybe (Dict (Compat (Pred a), CompatConstraint a (Pred a), CompatConstraint a ~ CompatConstraint (Pred a), CompatF a ~ CompatF (Pred a)))
- getCompatible :: forall a. (Compat a, CompatConstraint a a, Alternative (CompatF a), Monad (CompatF a)) => (forall c. (Compat c, CompatConstraint a c) => CompatF a c) -> CompatF a a
Documentation
A class for backwards-compatible data.
The predecessor for this type, i.e. the type for the data schema
directly preceeding a
.
type CompatConstraint a :: * -> Constraint Source #
Any additional constraints required to yield data values. Typically this will be a class that provides a parser.
type CompatF a :: * -> * Source #
A type for wrapping migration results. It is most useful if this type
has Alternative
and Monad
instances, enabling the use of
getCompatible
. Maybe
is a good first choice.
getCompatible :: forall a. (Compat a, CompatConstraint a a, Alternative (CompatF a), Monad (CompatF a)) => (forall c. (Compat c, CompatConstraint a c) => CompatF a c) -> CompatF a a Source #
Recursively migrate a data value to the most recent schema, if possible.