@@ -0,0 +1,46 @@
1+module LensSpec (spec, main) where
11+type ArraySchema = 'SchemaArray '[AEq 1] ('SchemaNumber '[NGt 10])
13+type ArrayField = '("foo", ArraySchema)
16+ '[ ArrayField, '("bar", 'SchemaOptional ('SchemaText '[TEnum '["foo", "bar"]]))]
18+type SchemaExample = 'SchemaObject FieldsSchema
20+arrayData :: JsonRepr ArraySchema
21+arrayData = ReprArray [ReprNumber 13]
23+arrayField :: FieldRepr ArrayField
24+arrayField = FieldRepr arrayData
26+objectData :: Rec FieldRepr FieldsSchema
27+objectData = FieldRepr arrayData
28+ :& FieldRepr (ReprOptional (Just (ReprText "foo")))
31+exampleData :: JsonRepr SchemaExample
32+exampleData = ReprObject objectData
36+ it "gets the field from an object" $ do
37+ fget (Proxy :: Proxy "foo") objectData == arrayField
38+ -- it "sets the object field" $ do
39+ -- fset (FieldRepr :: FieldRepr '("foo", ArrayField))
41+ describe "(using lens library) " $ do
42+ it "get the field from an object" $ do
43+ objectData ^. (flens (Proxy :: Proxy "foo")) == arrayField