@@ -6,7 +6,6 @@
66module Data.Schematic.Lens where
77
88import Data.Proxy
9−import Data.Schematic.Migration
109import Data.Schematic.Schema
1110import Data.Vinyl
1211import Data.Vinyl.Functor
@@ -44,32 +43,24 @@ class i ~ FIndex fn rs => FElem (fn :: Symbol) (rs :: [(Symbol, Schema)]) (i ::
4443
4544instance FElem fn ('(fn, r) ': rs) 'Z where
4645 type ByRevision fn ('(fn, r) ': rs) 'Z = r
46+
4747 flens _ f (x :& xs) = fmap (:& xs) (f x)
4848 {-# INLINE flens #-}
49+
4950 fget k = getConst . flens k Const
5051 {-# INLINE fget #-}
52+
5153 fput y = getIdentity . flens Proxy (\_ -> Identity y)
5254 {-# INLINE fput #-}
5355
5456instance (FIndex r (s ': rs) ~ 'S i, FElem r rs i) => FElem r (s ': rs) ('S i) where
5557 type ByRevision fn (s ': rs) ('S i) = ByRevision fn rs i
58+
5659 flens p f (x :& xs) = fmap (x :&) (flens p f xs)
5760 {-# INLINE flens #-}
61+
5862 fget k = getConst . flens k Const
5963 {-# INLINE fget #-}
64+
6065 fput y = getIdentity . flens Proxy (\_ -> Identity y)
6166 {-# INLINE fput #-}
62−
63−type SchemaExample
64− = 'SchemaObject
65− '[ '("foo", 'SchemaArray '[ 'AEq 1] ('SchemaNumber '[ 'NGt 10]))
66− , '("bar", 'SchemaOptional ('SchemaText '[ 'TEnum '["foo", "bar"]]))]
67−
68−type TestMigration =
69− 'Migration "test_revision"
70− '[ 'Diff '[ 'PKey "bar" ] ('Update ('SchemaText '[]))
71− , 'Diff '[ 'PKey "foo" ] ('Update ('SchemaNumber '[])) ]
72−
73−type VS = 'Versioned SchemaExample '[ TestMigration ]
74−
75−type Ex = FIndex "initial" (AllVersions VS)