schematic-0.5.0.0: JSON-biased spec and validation tool

Safe HaskellNone
LanguageHaskell2010

Data.Schematic.Migration

Synopsis

Documentation

data Path Source #

Constructors

PKey Symbol 
PTraverse 
Instances
SingI PTraverse Source # 
Instance details

Defined in Data.Schematic.Migration

Methods

sing :: Sing PTraverse #

KnownSymbol s => SingI (PKey s :: Path) Source # 
Instance details

Defined in Data.Schematic.Migration

Methods

sing :: Sing (PKey s) #

data Sing (p :: Path) Source # 
Instance details

Defined in Data.Schematic.Migration

data Sing (p :: Path) where

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 Action Source #

Instances
data Sing (a :: Action) Source # 
Instance details

Defined in Data.Schematic.Migration

data Sing (a :: Action) where

data Diff Source #

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

Constructors

Diff [Path] Action 
Instances
data Sing (diff :: Diff) Source # 
Instance details

Defined in Data.Schematic.Migration

data Sing (diff :: Diff) where

type Revision = Symbol Source #

User-provided name of the revision.

data Migration Source #

Constructors

Migration Revision [Diff] 
Instances
data Sing (m :: Migration) Source # 
Instance details

Defined in Data.Schematic.Migration

data Sing (m :: Migration) where

data Versioned Source #

Constructors

Versioned Schema [Migration] 
Instances
data Sing (v :: Versioned) Source # 
Instance details

Defined in Data.Schematic.Migration

data Sing (v :: Versioned) where

type DataMigration s m h = Tagged s (JsonRepr h -> m (JsonRepr s)) Source #

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

Constructors

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

migrateObject :: forall m fs fh. (FSubset fs fs (FImage fs fs), Monad m) => (Rec (Tagged fs :. FieldRepr) fh -> m (Rec (Tagged fs :. FieldRepr) fs)) -> Tagged (SchemaObject fs) (JsonRepr (SchemaObject fh) -> m (JsonRepr (SchemaObject fs))) Source #

shrinkObject :: forall rs ss m. (Monad m, FSubset rs ss (FImage rs ss)) => Tagged (SchemaObject rs) (JsonRepr (SchemaObject ss) -> m (JsonRepr (SchemaObject rs))) Source #

type family MapSnd (l :: [(a, k)]) = (r :: [k]) where ... Source #

Equations

MapSnd '[] = '[] 
MapSnd ('(a, b) ': tl) = b ': MapSnd tl