@@ -8,7 +8,7 @@ import Data.Schematic.Path
8import Data.Schematic.Schema
8import Data.Schematic.Schema
9import Data.Singletons.Prelude hiding (All)
9import Data.Singletons.Prelude hiding (All)
10import Data.Singletons.TypeLits
10import Data.Singletons.TypeLits
11−import Data.Vinyl hiding (Dict)
11+-- import Data.Vinyl hiding (Dict)
@@ -41,14 +41,17 @@ type family DeleteKey (acc :: [(Symbol, Schema)]) (fn :: Symbol) (fs :: [(Symbol
41 DeleteKey acc fn ('(fn, a) ': tl) = acc :++ tl
41 DeleteKey acc fn ('(fn, a) ': tl) = acc :++ tl
42 DeleteKey acc fn (fna ': tl) = acc :++ (fna ': tl)
42 DeleteKey acc fn (fna ': tl) = acc :++ (fna ': tl)
46+ (fs :: [(Symbol, Schema)])
44−type family UpdateKey (acc :: [(Symbol, Schema)]) (fn :: Symbol) (fs :: [(Symbol, Schema)]) (s :: Schema) :: [(Symbol, Schema)] where
47+ (s :: Schema) = (r :: [(Symbol, Schema)]) where
45− UpdateKey acc fn ( '(fn, n) ': tl ) s = '(fn, s) ': tl
48+ UpdateKey fn ( '(fn, a) ': tl ) s = ( '(fn, s) ': tl )
46− UpdateKey acc fn ( '(a, n) ': tl) s = UpdateKey (acc :++ '[ '(a,n) ]) fn tl s
49+ UpdateKey fn ( '(fs, a) ': tl ) s = ( '(fs, a) ': UpdateKey fn tl s)
48-- schema updates
51-- schema updates
50type family Build (b :: Builder) :: Schema where
53type 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))
52 Build ('BTraverse ('SchemaArray acs s) z) = 'SchemaArray acs (Build z)
55 Build ('BTraverse ('SchemaArray acs s) z) = 'SchemaArray acs (Build z)
53 Build ('BScalar s) = s
56 Build ('BScalar s) = s
@@ -77,10 +80,6 @@ type family SchemaByRevision (r :: Revision) (vd :: Versioned) :: Schema where
77 SchemaByRevision r ('Versioned s (m ': ms)) =
80 SchemaByRevision r ('Versioned s (m ': ms)) =
78 SchemaByRevision r ('Versioned (Snd (ApplyMigration m s)) ms)
81 SchemaByRevision r ('Versioned (Snd (ApplyMigration m s)) ms)
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
84type family ElemOf (e :: k) (l :: [(a,k)]) :: Constraint where
83type family ElemOf (e :: k) (l :: [(a,k)]) :: Constraint where
85 ElemOf e '[] = 'True ~ 'False
84 ElemOf e '[] = 'True ~ 'False
86 ElemOf e ( '(a, e) ': es) = ()
85 ElemOf e ( '(a, e) ': es) = ()
@@ -147,32 +146,18 @@ data instance Sing (v :: Versioned) where
147 -> Sing (ms :: [Migration]) -- a bunch of migrations
146 -> Sing (ms :: [Migration]) -- a bunch of migrations
148 -> Sing ('Versioned s ms)
147 -> Sing ('Versioned s ms)
150−-- data MList ms where
149+-- type SchemaExample
151−-- MSing :: proxy a -> MList '[a]
152−-- MCons :: Dict (MigrateSchema h a) -> proxy a -> MList (h ': tl) -> MList (a ': h ': tl)
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)
159− = 'SchemaObject
150+-- = 'SchemaObject
160− '[ '("foo", 'SchemaArray '[ 'AEq 1] ( 'SchemaNumber '[ 'NGt 10 ]))
151+-- '[ '("foo", 'SchemaArray '[ 'AEq 1] ( 'SchemaNumber '[ 'NGt 10 ]))
161− , '("bar", 'SchemaOptional ( 'SchemaText '[ 'TRegex "\\w+", 'TEnum '["foo", "bar"]]))]
152+-- , '("bar", 'SchemaOptional ( 'SchemaText '[ 'TRegex "\\w+", 'TEnum '["foo", "bar"]]))]
163−type VS =
154+-- type VS =
164− 'Versioned SchemaExample
155+-- 'Versioned SchemaExample
165− '[ 'Migration "test_revision"
156+-- '[ 'Migration "test_revision"
166− '[ 'Diff '[ 'PKey "foo" ] ('Update ('SchemaText '[])) ] ]
157+-- '[ 'Diff '[ 'PKey "foo" ] ('Update ('SchemaText '[])) ] ]
168−jsonExample :: JsonRepr (TopVersion (AllVersions VS))
159+-- jsonExample :: JsonRepr (TopVersion (AllVersions VS))
169−jsonExample = ReprObject $
160+-- jsonExample = ReprObject $
170− FieldRepr (ReprText "foo")
161+-- FieldRepr (ReprText "foo")
171− :& FieldRepr (ReprOptional (Just (ReprText "bar")))
162+-- :& FieldRepr (ReprOptional (Just (ReprText "bar")))
172− :& RNil
163+-- :& RNil
175−-- tail :: [a] -> [a]
176−-- sTail :: Sing s -> Sing (Tail s)
177−-- :: (Head (Tail foo))