@@ -6,7 +6,6 @@
6module Data.Schematic.Lens where
6module Data.Schematic.Lens where
8import Data.Proxy
8import Data.Proxy
9−import Data.Schematic.Migration
10import Data.Schematic.Schema
9import Data.Schematic.Schema
11import Data.Vinyl
10import Data.Vinyl
12import Data.Vinyl.Functor
11import Data.Vinyl.Functor
@@ -44,32 +43,24 @@ class i ~ FIndex fn rs => FElem (fn :: Symbol) (rs :: [(Symbol, Schema)]) (i ::
45instance FElem fn ('(fn, r) ': rs) 'Z where
44instance FElem fn ('(fn, r) ': rs) 'Z where
46 type ByRevision fn ('(fn, r) ': rs) 'Z = r
45 type ByRevision fn ('(fn, r) ': rs) 'Z = r
47 flens _ f (x :& xs) = fmap (:& xs) (f x)
47 flens _ f (x :& xs) = fmap (:& xs) (f x)
48 {-# INLINE flens #-}
48 {-# INLINE flens #-}
49 fget k = getConst . flens k Const
50 fget k = getConst . flens k Const
50 {-# INLINE fget #-}
51 {-# INLINE fget #-}
51 fput y = getIdentity . flens Proxy (\_ -> Identity y)
53 fput y = getIdentity . flens Proxy (\_ -> Identity y)
52 {-# INLINE fput #-}
54 {-# INLINE fput #-}
54instance (FIndex r (s ': rs) ~ 'S i, FElem r rs i) => FElem r (s ': rs) ('S i) where
56instance (FIndex r (s ': rs) ~ 'S i, FElem r rs i) => FElem r (s ': rs) ('S i) where
55 type ByRevision fn (s ': rs) ('S i) = ByRevision fn rs i
57 type ByRevision fn (s ': rs) ('S i) = ByRevision fn rs i
56 flens p f (x :& xs) = fmap (x :&) (flens p f xs)
59 flens p f (x :& xs) = fmap (x :&) (flens p f xs)
57 {-# INLINE flens #-}
60 {-# INLINE flens #-}
58 fget k = getConst . flens k Const
62 fget k = getConst . flens k Const
59 {-# INLINE fget #-}
63 {-# INLINE fget #-}
60 fput y = getIdentity . flens Proxy (\_ -> Identity y)
65 fput y = getIdentity . flens Proxy (\_ -> Identity y)
61 {-# INLINE fput #-}
66 {-# INLINE fput #-}
65− '[ '("foo", 'SchemaArray '[ 'AEq 1] ('SchemaNumber '[ 'NGt 10]))
66− , '("bar", 'SchemaOptional ('SchemaText '[ 'TEnum '["foo", "bar"]]))]
69− 'Migration "test_revision"
70− '[ 'Diff '[ 'PKey "bar" ] ('Update ('SchemaText '[]))
71− , 'Diff '[ 'PKey "foo" ] ('Update ('SchemaNumber '[])) ]
73−type VS = 'Versioned SchemaExample '[ TestMigration ]
75−type Ex = FIndex "initial" (AllVersions VS)