@@ -8,7 +8,7 @@ import Data.Schematic.Path
88import Data.Schematic.Schema
99import Data.Singletons.Prelude hiding (All)
1010import Data.Singletons.TypeLits
11−import Data.Vinyl hiding (Dict)
11+-- import Data.Vinyl hiding (Dict)
1212
1313
1414data Path
@@ -41,14 +41,17 @@ type family DeleteKey (acc :: [(Symbol, Schema)]) (fn :: Symbol) (fs :: [(Symbol
4141 DeleteKey acc fn ('(fn, a) ': tl) = acc :++ tl
4242 DeleteKey acc fn (fna ': tl) = acc :++ (fna ': tl)
4343
44−type family UpdateKey (acc :: [(Symbol, Schema)]) (fn :: Symbol) (fs :: [(Symbol, Schema)]) (s :: Schema) :: [(Symbol, Schema)] where
45− UpdateKey acc fn ( '(fn, n) ': tl ) s = '(fn, s) ': tl
46− UpdateKey acc fn ( '(a, n) ': tl) s = UpdateKey (acc :++ '[ '(a,n) ]) fn tl s
44+type family UpdateKey
45+ (fn :: Symbol)
46+ (fs :: [(Symbol, Schema)])
47+ (s :: Schema) = (r :: [(Symbol, Schema)]) where
48+ UpdateKey fn ( '(fn, a) ': tl ) s = ( '(fn, s) ': tl )
49+ UpdateKey fn ( '(fs, a) ': tl ) s = ( '(fs, a) ': UpdateKey fn tl s)
4750
4851-- schema updates
4952
5053type family Build (b :: Builder) :: Schema where
51− Build ('BKey ('SchemaObject fs) fn z) = 'SchemaObject (UpdateKey '[] fn fs (Build z))
54+ Build ('BKey ('SchemaObject fs) fn z) = 'SchemaObject (UpdateKey fn fs (Build z))
5255 Build ('BTraverse ('SchemaArray acs s) z) = 'SchemaArray acs (Build z)
5356 Build ('BScalar s) = s
5457
@@ -77,10 +80,6 @@ type family SchemaByRevision (r :: Revision) (vd :: Versioned) :: Schema where
7780 SchemaByRevision r ('Versioned s (m ': ms)) =
7881 SchemaByRevision r ('Versioned (Snd (ApplyMigration m s)) ms)
7982
80−-- type family Reverse (acc :: [(Revision, Schema)]) (rs :: [(Revision, Schema)]) :: [(Revision, Schema)] where
81−-- Reverse acc '[] = acc
82−-- Reverse acc (h ': tl) = Reverse (h ': acc) tl
83−
8483type family ElemOf (e :: k) (l :: [(a,k)]) :: Constraint where
8584 ElemOf e '[] = 'True ~ 'False
8685 ElemOf e ( '(a, e) ': es) = ()
@@ -147,32 +146,18 @@ data instance Sing (v :: Versioned) where
147146 -> Sing (ms :: [Migration]) -- a bunch of migrations
148147 -> Sing ('Versioned s ms)
149148
150−-- data MList ms where
151−-- MSing :: proxy a -> MList '[a]
152−-- MCons :: Dict (MigrateSchema h a) -> proxy a -> MList (h ': tl) -> MList (a ': h ': tl)
153−
154−-- data MList ms where
155−-- MSing :: proxy a -> MList '[a]
156−-- MCons :: (JsonRepr h -> JsonRepr a) -> proxy a -> MList (h ': tl) -> MList (a ': h ': tl)
157−
158−type SchemaExample
159− = 'SchemaObject
160− '[ '("foo", 'SchemaArray '[ 'AEq 1] ( 'SchemaNumber '[ 'NGt 10 ]))
161− , '("bar", 'SchemaOptional ( 'SchemaText '[ 'TRegex "\\w+", 'TEnum '["foo", "bar"]]))]
162−
163−type VS =
164− 'Versioned SchemaExample
165− '[ 'Migration "test_revision"
166− '[ 'Diff '[ 'PKey "foo" ] ('Update ('SchemaText '[])) ] ]
167−
168−jsonExample :: JsonRepr (TopVersion (AllVersions VS))
169−jsonExample = ReprObject $
170− FieldRepr (ReprText "foo")
171− :& FieldRepr (ReprOptional (Just (ReprText "bar")))
172− :& RNil
173−
174−
175−-- tail :: [a] -> [a]
176−-- sTail :: Sing s -> Sing (Tail s)
177−-- :: (Head (Tail foo))
178−-- sHead (sTail foo)
149+-- type SchemaExample
150+-- = 'SchemaObject
151+-- '[ '("foo", 'SchemaArray '[ 'AEq 1] ( 'SchemaNumber '[ 'NGt 10 ]))
152+-- , '("bar", 'SchemaOptional ( 'SchemaText '[ 'TRegex "\\w+", 'TEnum '["foo", "bar"]]))]
153+
154+-- type VS =
155+-- 'Versioned SchemaExample
156+-- '[ 'Migration "test_revision"
157+-- '[ 'Diff '[ 'PKey "foo" ] ('Update ('SchemaText '[])) ] ]
158+
159+-- jsonExample :: JsonRepr (TopVersion (AllVersions VS))
160+-- jsonExample = ReprObject $
161+-- FieldRepr (ReprText "foo")
162+-- :& FieldRepr (ReprOptional (Just (ReprText "bar")))
163+-- :& RNil