git.iko.soy/typeable/schematic
on master help sign in
compilation workaround
ec1996dDenis Redozubov
src/Data/Schematic/Schema.hs+1−1
@@ -327,7 +327,7 @@ data JsonRepr :: Schema -> Type where
327 ReprArray :: V.Vector (JsonRepr s) -> JsonRepr ('SchemaArray cs s)
327 ReprArray :: V.Vector (JsonRepr s) -> JsonRepr ('SchemaArray cs s)
328 ReprObject :: Rec FieldRepr fs -> JsonRepr ('SchemaObject fs)
328 ReprObject :: Rec FieldRepr fs -> JsonRepr ('SchemaObject fs)
329 ReprOptional :: Maybe (JsonRepr s) -> JsonRepr ('SchemaOptional s)
329 ReprOptional :: Maybe (JsonRepr s) -> JsonRepr ('SchemaOptional s)
330− ReprUnion :: Union JsonRepr s -> JsonRepr ('SchemaUnion ss)
330+ ReprUnion :: Union JsonRepr (h ': tl) -> JsonRepr ('SchemaUnion (h ': tl))
331
331
332-- | Move to the different package
332-- | Move to the different package
333type family UnionAll (f :: u -> *) (rs :: [u]) (c :: * -> Constraint) :: Constraint where
333type family UnionAll (f :: u -> *) (rs :: [u]) (c :: * -> Constraint) :: Constraint where
src/Data/Schematic/Validation.hs+18−7
@@ -206,10 +206,21 @@ validateJsonRepr sschema dpath jr = case jr of
206 let newPath = dpath <> [DKey (knownFieldName f)]
206 let newPath = dpath <> [DKey (knownFieldName f)]
207 validateJsonRepr (knownFieldSchema f) newPath d
207 validateJsonRepr (knownFieldSchema f) newPath d
208 go ftl
208 go ftl
209− ReprUnion u -> case sschema of
209+ ReprUnion u -> pure () -- case sschema of
210− SSchemaUnion ss -> case ss of
210+ -- SSchemaUnion ss -> case ss of
211+ -- SNil -> do
212+ -- let JSONPath path = demotedPathToText dpath
211− SNil -> vWarning $ mmSingleton (demotedPathToText dpath)
213+ -- void $ vWarning $ mmSingleton path
212− $ pure "union handling error, please report this as bug"
214+ -- $ pure "union handling error, please report this as bug"
213− SCons s stl -> case u of
215+ -- SCons s stl -> case umatch' s u of
216+ -- Nothing -> case urestrict u of
217+ -- Nothing -> fail "impossible to urestrict union, please report this as a bug"
218+ -- Just x -> do
219+ -- let
220+ -- toUnion :: Sing ss -> Union JsonRepr ss -> JsonRepr ('SchemaUnion ss)
221+ -- toUnion _ = ReprUnion
222+ -- validateJsonRepr (SSchemaUnion stl) dpath $ toUnion stl x
214− This x -> validateJsonRepr s dpath x
223+ -- Just x -> validateJsonRepr s dpath x
215− That u' -> validateJsonRepr (SSchemaUnion ss) dpath (ReprUnion u')
224+
225+umatch' :: UElem a as i => Sing a -> Union f as -> Maybe (f a)
226+umatch' _ u = umatch u