data-compat-0.1.0.0: Define Backwards Compatibility Schemes for Arbitrary Data

CopyrightTravis Whitaker 2019
LicenseMIT
Maintainerpi.boy.travis@gmail.com
StabilityProvisional
PortabilityPortable
Safe HaskellSafe
LanguageHaskell2010

Data.Compat

Description

See http://programmable.computer/compatible.hs for a full exposition and worked examples.

Synopsis

Documentation

class Compat a where Source #

A class for backwards-compatible data.

Associated Types

type Pred a :: * Source #

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.

Methods

migrate :: Pred a -> CompatF a a Source #

How to migrate from a value of the preceeding schema to the current schema.

continue :: Proxy a -> Maybe (Dict (Compat (Pred a), CompatConstraint a (Pred a), CompatConstraint a ~ CompatConstraint (Pred a), CompatF a ~ CompatF (Pred a))) Source #

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.