schematic-0.2.1.0: JSON-biased spec and validation tool

Safe HaskellNone
LanguageHaskell2010

Data.Schematic.Migration

Synopsis

Documentation

data Path Source #

Constructors

PKey Symbol 
PTraverse 

Instances

type family SchemaByKey (fs :: [(Symbol, Schema)]) (s :: Symbol) :: Schema where ... Source #

Equations

SchemaByKey ('(fn, s) ': tl) fn = s 
SchemaByKey ('(a, s) ': tl) fn = SchemaByKey tl fn 

type family DeleteKey (acc :: [(Symbol, Schema)]) (fn :: Symbol) (fs :: [(Symbol, Schema)]) :: [(Symbol, Schema)] where ... Source #

Equations

DeleteKey acc fn ('(fn, a) ': tl) = acc :++ tl 
DeleteKey acc fn (fna ': tl) = acc :++ (fna ': tl) 

type family UpdateKey (fn :: Symbol) (fs :: [(Symbol, Schema)]) (s :: Schema) = (r :: [(Symbol, Schema)]) where ... Source #

Equations

UpdateKey fn ('(fn, a) ': tl) s = '(fn, s) ': tl 
UpdateKey fn ('(fs, a) ': tl) s = '(fs, a) ': UpdateKey fn tl s 

type family Build (b :: Builder) :: Schema where ... Source #

Equations

Build (BKey (SchemaObject fs) fn z) = SchemaObject (UpdateKey fn fs (Build z)) 
Build (BTraverse (SchemaArray acs s) z) = SchemaArray acs (Build z) 
Build (BScalar s) = s 

type family MakeBuilder (s :: Schema) (d :: Diff) :: Builder where ... Source #

Equations

MakeBuilder s (Diff '[] a) = BScalar (ApplyAction a s) 
MakeBuilder (SchemaObject fs) (Diff (PKey fn ': tl) a) = BKey (SchemaObject fs) fn (MakeBuilder (SchemaByKey fs fn) (Diff tl a)) 
MakeBuilder (SchemaArray acs s) (Diff (PTraverse ': tl) a) = BTraverse (SchemaArray acs s) (MakeBuilder s (Diff tl a)) 

type family ApplyAction (a :: Action) (s :: Schema) :: Schema where ... Source #

Equations

ApplyAction (AddKey fn s) (SchemaObject fs) = SchemaObject ('(fn, s) ': fs) 
ApplyAction (DeleteKey fn) (SchemaObject fs) = SchemaObject (DeleteKey '[] fn fs) 
ApplyAction (Update s) t = s 

type family ApplyMigration (m :: Migration) (s :: Schema) :: (Revision, Schema) where ... Source #

Equations

ApplyMigration (Migration r '[]) s = '(r, s) 
ApplyMigration (Migration r (d ': ds)) s = '(r, Snd (ApplyMigration (Migration r ds) (Build (MakeBuilder s d)))) 

type family SchemaByRevision (r :: Revision) (vd :: Versioned) :: Schema where ... Source #

Equations

SchemaByRevision r (Versioned s (Migration r ds ': ms)) = Snd (ApplyMigration (Migration r ds) s) 
SchemaByRevision r (Versioned s (m ': ms)) = SchemaByRevision r (Versioned (Snd (ApplyMigration m s)) ms) 

type family InitialSchema (v :: Versioned) = (s :: Schema) where ... Source #

Equations

InitialSchema (Versioned s ms) = s 

type family ElemOf (e :: k) (l :: [(a, k)]) :: Constraint where ... Source #

Equations

ElemOf e '[] = True ~ False 
ElemOf e ('(a, e) ': es) = () 
ElemOf e (n ': es) = ElemOf e es 

type family AllVersions (vd :: Versioned) :: [(Revision, Schema)] where ... Source #

Extracts revision/schema pairs from Versioned in reverse order.

Equations

AllVersions (Versioned s ms) = Reverse (AllVersions' '['("initial", s)] ms) 

type family AllVersions' (acc :: [(Revision, Schema)]) (ms :: [Migration]) = (r :: [(Revision, Schema)]) where ... Source #

Equations

AllVersions' acc '[] = acc 
AllVersions' ('(rh, sh) ': tl) (m ': ms) = AllVersions' ('(rh, sh) ': (ApplyMigration m sh ': tl)) ms 

type family TopVersion (rs :: [(Revision, Schema)]) :: Schema where ... Source #

Equations

TopVersion ('(rh, sh) ': tl) = sh 

data Diff Source #

User-supplied atomic difference between schemas. Migrations can consists of many differences.

Constructors

Diff [Path] Action 

Instances

data Sing Diff Source # 
data Sing Diff where

type Revision = Symbol Source #

User-provided name of the revision.

data Migration Source #

Constructors

Migration Revision [Diff] 

Instances

data Versioned Source #

Constructors

Versioned Schema [Migration] 

Instances

data MList :: (* -> *) -> [Schema] -> Type where Source #

Constructors

MNil :: (Monad m, SingI s, TopLevel s) => MList m '[s] 
(:&&) :: (TopLevel s, SingI s) => proxy s -> (JsonRepr h -> m (JsonRepr s)) -> MList m (h ': tl) -> MList m (s ': (h ': tl)) infixr 7