-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | JSON-biased spec and validation tool -- -- JSON-biased spec and validation tool. Makes possible to have a schema -- as a haskell type and derive json instances, validation actions, JSON -- generation for property-test generically. Built-in lens support. @package schematic @version 0.5.0.0 module Data.Schematic.Generator.Regex minRepeat :: Int maxRepeat :: Int regexSeries :: (Monad m) => Text -> Series m Text regexSeries' :: (Monad m) => Pattern -> Series m Builder module Data.Schematic.Instances instance forall u (m :: * -> *) (f :: u -> *). GHC.Base.Monad m => Test.SmallCheck.Series.Serial m (Data.Vinyl.Core.Rec f '[]) instance forall a1 (m :: * -> *) (f :: a1 -> *) (a2 :: a1) (as :: [a1]). (Test.SmallCheck.Series.Serial m (f a2), Test.SmallCheck.Series.Serial m (Data.Vinyl.Core.Rec f as), GHC.Base.Monad m) => Test.SmallCheck.Series.Serial m (Data.Vinyl.Core.Rec f (a2 : as)) instance Test.SmallCheck.Series.Serial m a => Test.SmallCheck.Series.Serial m (Data.Vector.Vector a) instance GHC.Base.Monad m => Test.SmallCheck.Series.Serial m Data.Scientific.Scientific instance GHC.Base.Monad m => Test.SmallCheck.Series.Serial m Data.Text.Internal.Text module Data.Schematic.Path data PathSegment Key :: Symbol -> PathSegment Ix :: Nat -> PathSegment data DemotedPathSegment DKey :: Text -> DemotedPathSegment DIx :: Integer -> DemotedPathSegment -- | Textual representation of json path. newtype JSONPath JSONPath :: Text -> JSONPath demotePath :: Sing (ps :: [PathSegment]) -> [DemotedPathSegment] demotedPathToText :: [DemotedPathSegment] -> JSONPath pathToText :: Sing (ps :: [PathSegment]) -> JSONPath instance GHC.Show.Show Data.Schematic.Path.JSONPath instance GHC.Show.Show Data.Schematic.Path.DemotedPathSegment module Data.Schematic.Verifier.Common simplifyNumberConstraint :: ([Integer] -> Integer) -> [Integer] -> Maybe Integer simplifyDNLs :: [Integer] -> Maybe Integer simplifyDNGs :: [Integer] -> Maybe Integer verifyDNEq :: [Integer] -> Maybe (Maybe Integer) verify3 :: Maybe Integer -> Maybe Integer -> Maybe Integer -> Maybe () verify2 :: Maybe Integer -> Maybe Integer -> Maybe () verifyEquations :: Maybe Integer -> Maybe Integer -> Maybe Integer -> Maybe () module Data.Schematic.Verifier.Array data VerifiedArrayConstraint VAEq :: Integer -> VerifiedArrayConstraint verifyArrayConstraint :: [DemotedArrayConstraint] -> Maybe (Maybe VerifiedArrayConstraint) instance GHC.Show.Show Data.Schematic.Verifier.Array.VerifiedArrayConstraint module Data.Schematic.Verifier.Number toStrictNumber :: [DemotedNumberConstraint] -> [DemotedNumberConstraint] data VerifiedNumberConstraint VNEq :: Integer -> VerifiedNumberConstraint VNBounds :: (Maybe Integer) -> (Maybe Integer) -> VerifiedNumberConstraint verifyNumberConstraints :: [DemotedNumberConstraint] -> Maybe VerifiedNumberConstraint instance GHC.Show.Show Data.Schematic.Verifier.Number.VerifiedNumberConstraint module Data.Schematic.Verifier.Text toStrictTextLength :: [DemotedTextConstraint] -> [DemotedTextConstraint] data VerifiedTextConstraint VTEq :: Integer -> VerifiedTextConstraint VTBounds :: (Maybe Integer) -> (Maybe Integer) -> VerifiedTextConstraint VTRegex :: Text -> Integer -> (Maybe Integer) -> VerifiedTextConstraint VTEnum :: [Text] -> VerifiedTextConstraint verifyTextLengthConstraints :: [DemotedTextConstraint] -> Maybe (Maybe VerifiedTextConstraint) regexLength :: Text -> Maybe (Int, Maybe Int) minRegexLength :: Pattern -> Int maxRegexLength :: Pattern -> Maybe Int verifyTextRegexConstraint :: [DemotedTextConstraint] -> Maybe (Maybe VerifiedTextConstraint) verifyTextEnumConstraint :: [DemotedTextConstraint] -> Maybe (Maybe VerifiedTextConstraint) verifyTextConstraints :: [DemotedTextConstraint] -> Maybe [VerifiedTextConstraint] instance GHC.Show.Show Data.Schematic.Verifier.Text.VerifiedTextConstraint module Data.Schematic.Verifier module Data.Schematic.Generator maxHigh :: Int minLow :: Int textLengthSeries :: Monad m => [VerifiedTextConstraint] -> Series m Text textEnumSeries :: Monad m => [Text] -> Series m Text textSeries :: Monad m => [DemotedTextConstraint] -> Series m Text textSeries' :: Monad m => [VerifiedTextConstraint] -> Series m Text numberSeries :: Monad m => [DemotedNumberConstraint] -> Series m Scientific numberSeries' :: Monad m => VerifiedNumberConstraint -> Series m Scientific arraySeries :: (Monad m, Serial m (JsonRepr s)) => [DemotedArrayConstraint] -> Series m (Vector (JsonRepr s)) arraySeries' :: forall m s. (Monad m, Serial m (JsonRepr s)) => Maybe VerifiedArrayConstraint -> Series m (Vector (JsonRepr s)) module Data.Schematic.Schema data TextConstraint TEq :: Nat -> TextConstraint TLt :: Nat -> TextConstraint TLe :: Nat -> TextConstraint TGt :: Nat -> TextConstraint TGe :: Nat -> TextConstraint TRegex :: Symbol -> TextConstraint TEnum :: [Symbol] -> TextConstraint data DemotedTextConstraint DTEq :: Integer -> DemotedTextConstraint DTLt :: Integer -> DemotedTextConstraint DTLe :: Integer -> DemotedTextConstraint DTGt :: Integer -> DemotedTextConstraint DTGe :: Integer -> DemotedTextConstraint DTRegex :: Text -> DemotedTextConstraint DTEnum :: [Text] -> DemotedTextConstraint data NumberConstraint NLe :: Nat -> NumberConstraint NLt :: Nat -> NumberConstraint NGt :: Nat -> NumberConstraint NGe :: Nat -> NumberConstraint NEq :: Nat -> NumberConstraint data DemotedNumberConstraint DNLe :: Integer -> DemotedNumberConstraint DNLt :: Integer -> DemotedNumberConstraint DNGt :: Integer -> DemotedNumberConstraint DNGe :: Integer -> DemotedNumberConstraint DNEq :: Integer -> DemotedNumberConstraint data ArrayConstraint AEq :: Nat -> ArrayConstraint data DemotedArrayConstraint DAEq :: Integer -> DemotedArrayConstraint data Schema SchemaText :: [TextConstraint] -> Schema SchemaBoolean :: Schema SchemaNumber :: [NumberConstraint] -> Schema SchemaObject :: [(Symbol, Schema)] -> Schema SchemaArray :: [ArrayConstraint] -> Schema -> Schema SchemaNull :: Schema SchemaOptional :: Schema -> Schema SchemaUnion :: [Schema] -> Schema data DemotedSchema DSchemaText :: [DemotedTextConstraint] -> DemotedSchema DSchemaNumber :: [DemotedNumberConstraint] -> DemotedSchema DSchemaBoolean :: DemotedSchema DSchemaObject :: [(Text, DemotedSchema)] -> DemotedSchema DSchemaArray :: [DemotedArrayConstraint] -> DemotedSchema -> DemotedSchema DSchemaNull :: DemotedSchema DSchemaOptional :: DemotedSchema -> DemotedSchema DSchemaUnion :: [DemotedSchema] -> DemotedSchema data FieldRepr :: (Symbol, Schema) -> Type [FieldRepr] :: (SingI schema, KnownSymbol name) => JsonRepr schema -> FieldRepr '(name, schema) -- | Forgetful Functor Ufr toJsonRepr :: FieldRepr '(fn, sch) -> JsonRepr sch knownFieldName :: forall proxy (fieldName :: Symbol) schema. KnownSymbol fieldName => proxy '(fieldName, schema) -> Text knownFieldSchema :: forall proxy fieldName schema. SingI schema => proxy '(fieldName, schema) -> Sing schema data JsonRepr :: Schema -> Type [ReprText] :: Text -> JsonRepr ( 'SchemaText cs) [ReprNumber] :: Scientific -> JsonRepr ( 'SchemaNumber cs) [ReprBoolean] :: Bool -> JsonRepr 'SchemaBoolean [ReprNull] :: JsonRepr 'SchemaNull [ReprArray] :: Vector (JsonRepr s) -> JsonRepr ( 'SchemaArray cs s) [ReprObject] :: Rec FieldRepr fs -> JsonRepr ( 'SchemaObject fs) [ReprOptional] :: Maybe (JsonRepr s) -> JsonRepr ( 'SchemaOptional s) [ReprUnion] :: Union JsonRepr (h : tl) -> JsonRepr ( 'SchemaUnion (h : tl)) fromOptional :: SingI s => Sing ( 'SchemaOptional s) -> Value -> Parser (Maybe (JsonRepr s)) parseUnion :: FromJSON (JsonRepr ( 'SchemaUnion ss)) => sing (ss :: [Schema]) -> Value -> Parser (JsonRepr ( 'SchemaUnion ss)) class FalseConstraint a instance GHC.Show.Show Data.Schematic.Schema.DemotedSchema instance GHC.Classes.Eq Data.Schematic.Schema.DemotedSchema instance GHC.Generics.Generic Data.Schematic.Schema.DemotedSchema instance GHC.Generics.Generic Data.Schematic.Schema.Schema instance GHC.Show.Show Data.Schematic.Schema.DemotedArrayConstraint instance GHC.Classes.Eq Data.Schematic.Schema.DemotedArrayConstraint instance GHC.Generics.Generic Data.Schematic.Schema.DemotedArrayConstraint instance GHC.Generics.Generic Data.Schematic.Schema.ArrayConstraint instance GHC.Show.Show Data.Schematic.Schema.DemotedNumberConstraint instance GHC.Classes.Eq Data.Schematic.Schema.DemotedNumberConstraint instance GHC.Generics.Generic Data.Schematic.Schema.DemotedNumberConstraint instance GHC.Generics.Generic Data.Schematic.Schema.NumberConstraint instance GHC.Show.Show Data.Schematic.Schema.DemotedTextConstraint instance GHC.Classes.Eq Data.Schematic.Schema.DemotedTextConstraint instance GHC.Generics.Generic Data.Schematic.Schema.DemotedTextConstraint instance GHC.Generics.Generic Data.Schematic.Schema.TextConstraint instance GHC.Show.Show (Data.Schematic.Schema.JsonRepr schema) => GHC.Show.Show (Data.Schematic.Schema.FieldRepr '(name, schema)) instance GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr schema) => GHC.Classes.Eq (Data.Schematic.Schema.FieldRepr '(name, schema)) instance (GHC.TypeLits.KnownSymbol name, Data.Singletons.Internal.SingI schema, Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr schema)) => Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.FieldRepr '(name, schema)) instance (GHC.Base.Monad m, Test.SmallCheck.Series.Serial m Data.Text.Internal.Text, Data.Singletons.Internal.SingI cs) => Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaText cs)) instance (GHC.Base.Monad m, Test.SmallCheck.Series.Serial m Data.Scientific.Scientific, Data.Singletons.Internal.SingI cs) => Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaNumber cs)) instance GHC.Base.Monad m => Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr 'Data.Schematic.Schema.SchemaNull) instance (Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr s), Test.SmallCheck.Series.Serial m (Data.Vector.Vector (Data.Schematic.Schema.JsonRepr s)), Data.Singletons.Internal.SingI cs) => Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaArray cs s)) instance Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr s) => Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaOptional s)) instance (GHC.Base.Monad m, Test.SmallCheck.Series.Serial m (Data.Vinyl.Core.Rec Data.Schematic.Schema.FieldRepr fs)) => Test.SmallCheck.Series.Serial m (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaObject fs)) instance GHC.Show.Show (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaText cs)) instance GHC.Show.Show (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaNumber cs)) instance GHC.Show.Show (Data.Schematic.Schema.JsonRepr 'Data.Schematic.Schema.SchemaNull) instance GHC.Show.Show (Data.Schematic.Schema.JsonRepr s) => GHC.Show.Show (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaArray acs s)) instance Data.Vinyl.TypeLevel.RecAll Data.Schematic.Schema.FieldRepr fs GHC.Show.Show => GHC.Show.Show (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaObject fs)) instance GHC.Show.Show (Data.Schematic.Schema.JsonRepr s) => GHC.Show.Show (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaOptional s)) instance GHC.Classes.Eq (Data.Vinyl.Core.Rec Data.Schematic.Schema.FieldRepr fs) => GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaObject fs)) instance GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaText cs)) instance GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaNumber cs)) instance GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr 'Data.Schematic.Schema.SchemaNull) instance GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr s) => GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaArray as s)) instance GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr s) => GHC.Classes.Eq (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaOptional s)) instance GHC.Classes.Ord (Data.Vinyl.Core.Rec Data.Schematic.Schema.FieldRepr fs) => GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaObject fs)) instance GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaText cs)) instance GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaNumber cs)) instance GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr 'Data.Schematic.Schema.SchemaNull) instance GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr s) => GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaArray as s)) instance GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr s) => GHC.Classes.Ord (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaOptional s)) instance GHC.Exts.IsList (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaArray cs s)) instance GHC.Num.Num (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaNumber cs)) instance Data.String.IsString (Data.Schematic.Schema.JsonRepr ('Data.Schematic.Schema.SchemaText cs)) instance Data.Aeson.Types.FromJSON.FromJSON (Data.Union.Union Data.Schematic.Schema.JsonRepr '[]) instance (Data.Singletons.Internal.SingI a, Data.Aeson.Types.FromJSON.FromJSON (Data.Union.Union Data.Schematic.Schema.JsonRepr as)) => Data.Aeson.Types.FromJSON.FromJSON (Data.Union.Union Data.Schematic.Schema.JsonRepr (a : as)) instance Data.Aeson.Types.ToJSON.ToJSON (Data.Union.Union Data.Schematic.Schema.JsonRepr as) instance Data.Singletons.Internal.SingI schema => Data.Aeson.Types.FromJSON.FromJSON (Data.Schematic.Schema.JsonRepr schema) instance Data.Aeson.Types.ToJSON.ToJSON (Data.Schematic.Schema.JsonRepr a) instance Data.Singletons.Internal.SingKind Data.Schematic.Schema.Schema instance Data.Singletons.Internal.SingI sl => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.SchemaText sl) instance Data.Singletons.Internal.SingI sl => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.SchemaNumber sl) instance Data.Singletons.Internal.SingI 'Data.Schematic.Schema.SchemaNull instance Data.Singletons.Internal.SingI 'Data.Schematic.Schema.SchemaBoolean instance (Data.Singletons.Internal.SingI ac, Data.Singletons.Internal.SingI s) => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.SchemaArray ac s) instance Data.Singletons.Internal.SingI stl => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.SchemaObject stl) instance Data.Singletons.Internal.SingI s => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.SchemaOptional s) instance Data.Singletons.Internal.SingI s => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.SchemaUnion s) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.SchemaText cs)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.SchemaNumber cs)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing 'Data.Schematic.Schema.SchemaNull) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing 'Data.Schematic.Schema.SchemaBoolean) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.SchemaArray as s)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.SchemaObject cs)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.SchemaOptional s)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.SchemaUnion s)) instance Data.Singletons.Internal.SingKind Data.Schematic.Schema.ArrayConstraint instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.AEq n) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.AEq n)) instance Data.Singletons.Internal.SingKind Data.Schematic.Schema.NumberConstraint instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.NEq n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.NGt n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.NGe n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.NLt n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.NLe n) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.NEq n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.NLt n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.NLe n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.NGt n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.NGe n)) instance Data.Singletons.Internal.SingKind Data.Schematic.Schema.TextConstraint instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.TEq n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.TGt n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.TGe n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.TLt n) instance GHC.TypeNats.KnownNat n => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.TLe n) instance (GHC.TypeLits.KnownSymbol s, Data.Singletons.Internal.SingI s) => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.TRegex s) instance Data.Singletons.Internal.SingI ss => Data.Singletons.Internal.SingI ('Data.Schematic.Schema.TEnum ss) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.TEq n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.TLt n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.TLe n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.TGt n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.TGe n)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.TRegex t)) instance GHC.Classes.Eq (Data.Singletons.Internal.Sing ('Data.Schematic.Schema.TEnum ss)) module Data.Schematic.Validation type Validation a = ValidationT ErrorMap Identity a type ErrorMap = MonoidMap Text [Text] data ParseResult a Valid :: a -> ParseResult a DecodingError :: Text -> ParseResult a ValidationError :: ErrorMap -> ParseResult a isValid :: ParseResult a -> Bool isDecodingError :: ParseResult a -> Bool isValidationError :: ParseResult a -> Bool validateTextConstraint :: JSONPath -> Text -> Sing (tcs :: TextConstraint) -> Validation () validateNumberConstraint :: JSONPath -> Scientific -> Sing (tcs :: NumberConstraint) -> Validation () validateArrayConstraint :: JSONPath -> Vector a -> Sing (tcs :: ArrayConstraint) -> Validation () validateJsonRepr :: Sing schema -> [DemotedPathSegment] -> JsonRepr schema -> Validation () toUnion :: USubset s' (s : ss) (RImage s' (s : ss)) => Sing (s : ss) -> Union JsonRepr s' -> JsonRepr ( 'SchemaUnion (s : ss)) umatch' :: UElem a as i => Sing a -> Union f as -> Maybe (f a) parseAndValidateJson :: forall schema. (FromJSON (JsonRepr schema), TopLevel schema, SingI schema) => Value -> ParseResult (JsonRepr schema) parseAndValidateJsonBy :: (FromJSON (JsonRepr schema), TopLevel schema, SingI schema) => proxy schema -> Value -> ParseResult (JsonRepr schema) instance Data.Traversable.Traversable Data.Schematic.Validation.ParseResult instance Data.Foldable.Foldable Data.Schematic.Validation.ParseResult instance GHC.Base.Functor Data.Schematic.Validation.ParseResult instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Schematic.Validation.ParseResult a) instance GHC.Show.Show a => GHC.Show.Show (Data.Schematic.Validation.ParseResult a) instance (Data.Schematic.Schema.TopLevel a, Data.Singletons.Internal.SingI a, Data.Aeson.Types.FromJSON.FromJSON (Data.Schematic.Schema.JsonRepr a)) => Data.Aeson.Types.FromJSON.FromJSON (Data.Schematic.Validation.ParseResult (Data.Schematic.Schema.JsonRepr a)) module Data.Schematic.Lens -- | A partial relation that gives the index of a value in a list. class i ~ FIndex fn rs => FElem (fn :: Symbol) (rs :: [(Symbol, Schema)]) (i :: Nat) where { type family ByField fn rs i :: Schema; } flens :: FElem fn rs i => Flens fn f g rs i -- | For Vinyl users who are not using the lens package, we -- provide a getter. fget :: FElem fn rs i => FGetter fn f rs i -- | For Vinyl users who are not using the lens package, we also -- provide a setter. In general, it will be unambiguous what field is -- being written to, and so we do not take a proxy argument here. fput :: FElem fn rs i => f '(fn, ByField fn rs i) -> Rec f rs -> Rec f rs -- | A partial relation that gives the indices of a sublist in a larger -- list. class is ~ FImage rs ss => FSubset (rs :: [(Symbol, Schema)]) (ss :: [(Symbol, Schema)]) is -- | This is a lens into a slice of the larger record. Morally, we have: -- --
--   fsubset :: Lens' (Rec FieldRepr ss) (Rec FieldRepr rs)
--   
fsubset :: (FSubset rs ss is, Functor g) => (Rec f rs -> g (Rec f rs)) -> Rec f ss -> g (Rec f ss) -- | The getter of the fsubset lens is fcast, which takes a -- larger record to a smaller one by forgetting fields. fcast :: FSubset rs ss is => Rec f ss -> Rec f rs -- | The setter of the fsubset lens is freplace, which allows -- a slice of a record to be replaced with different values. freplace :: FSubset rs ss is => Rec f rs -> Rec f ss -> Rec f ss obj :: Iso' (JsonRepr ( 'SchemaObject fields)) (Rec FieldRepr fields) arr :: Iso' (JsonRepr ( 'SchemaArray cs schema)) (Vector (JsonRepr schema)) uni :: Iso' (JsonRepr ( 'SchemaUnion (h : tl))) (Union JsonRepr (h : tl)) txt :: Iso' (JsonRepr ( 'SchemaText cs)) Text num :: Iso' (JsonRepr ( 'SchemaNumber cs)) Scientific opt :: Iso' (JsonRepr ( 'SchemaOptional schema)) (Maybe (JsonRepr schema)) bln :: Iso' (JsonRepr 'SchemaBoolean) Bool textRepr :: (KnownSymbol fn, SingI cs) => Iso' (FieldRepr '(fn, ( 'SchemaText cs))) Text numberRepr :: (KnownSymbol fn, SingI cs) => Iso' (FieldRepr '(fn, ( 'SchemaNumber cs))) Scientific boolRepr :: (KnownSymbol fn) => Iso' (FieldRepr '(fn, 'SchemaBoolean)) Bool arrayRepr :: (KnownSymbol fn, SingI cs, SingI schema) => Iso' (FieldRepr '(fn, ( 'SchemaArray cs schema))) (Vector (JsonRepr schema)) objectRepr :: (KnownSymbol fn, SingI fields) => Iso' (FieldRepr '(fn, ( 'SchemaObject fields))) (Rec FieldRepr fields) optionalRepr :: (KnownSymbol fn, SingI schema) => Iso' (FieldRepr '(fn, ( 'SchemaOptional schema))) (Maybe (JsonRepr schema)) instance Data.Schematic.Lens.FSubset '[] ss '[] instance (Data.Schematic.Lens.ByField fn ss i ~ s, Data.Schematic.Lens.FElem fn ss i, Data.Schematic.Lens.FSubset rs ss is) => Data.Schematic.Lens.FSubset ('(fn, s) : rs) ss (i : is) instance Data.Schematic.Lens.FElem fn ('(fn, r) : rs) 'Data.Vinyl.TypeLevel.Z instance (Data.Schematic.Lens.FIndex r (s : rs) ~ 'Data.Vinyl.TypeLevel.S i, Data.Schematic.Lens.FElem r rs i) => Data.Schematic.Lens.FElem r (s : rs) ('Data.Vinyl.TypeLevel.S i) module Data.Schematic.JsonSchema toJsonSchema :: forall proxy schema. SingI schema => proxy (schema :: Schema) -> Maybe Schema toJsonSchema' :: DemotedSchema -> Maybe Schema module Data.Schematic.Helpers type UUIDRegex = 'TRegex "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" type IsUUID = '[UUIDRegex] type ISO8601Date = "[1-9][0-9]{3}-(0[1-9]|1[0-2])-([0-2][0-9]|3[0-1])" type ISO8601Time = "([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]" type ISO8601DateTime = AppendSymbol ISO8601Date (AppendSymbol "(T" (AppendSymbol ISO8601Time ")?")) type ISO8601UTC = "(Z|\\+00:00)" type ISO8601DateTimeUTC = AppendSymbol ISO8601Date (AppendSymbol "T" (AppendSymbol ISO8601Time ISO8601UTC)) type ISO8601TZ = "\\+[0-1][0-9]:[0-6][0-9]" type ISO8601DateTimeZoned = AppendSymbol ISO8601Date (AppendSymbol "T" (AppendSymbol ISO8601Time ISO8601TZ)) type ISO8601DateRegex = 'TRegex ISO8601Date type ISO8601TimeRegex = 'TRegex ISO8601Time type ISO8601DateTimeRegex = 'TRegex ISO8601DateTime type ISO8601DateTimeRegexUTC = 'TRegex ISO8601DateTimeUTC type ISO8601DateTimeRegexZoned = 'TRegex ISO8601DateTimeZoned type IsDate = '[ISO8601DateRegex] type IsTime = '[ISO8601TimeRegex] type IsDateTime = '[ISO8601DateTimeRegex] type IsZonedDateTime = '[ISO8601DateTimeRegexZoned] type IsUTCDateTime = '[ISO8601DateTimeRegexUTC] module Data.Schematic.DSL type Constructor a = forall fields b. (fields ~ FieldsOf a, FSubset fields b (FImage fields b)) => Rec (Tagged fields :. FieldRepr) b -> JsonRepr ( 'SchemaObject fields) withRepr :: Constructor a class Representable s constructField :: Representable s => Sing fn -> Proxy s -> Repr s -> FieldRepr '(fn, s) construct :: Sing s -> Repr s -> JsonRepr s type FieldConstructor fn = forall byField fs. (byField ~ ByField fn fs (FIndex fn fs), Representable byField) => Repr byField -> (Tagged fs :. FieldRepr) '(fn, byField) field :: forall fn. KnownSymbol fn => FieldConstructor fn instance Data.Singletons.Internal.SingI so => Data.Schematic.DSL.Representable ('Data.Schematic.Schema.SchemaObject so) instance (Data.Singletons.Internal.SingI cs, Data.Singletons.Internal.SingI sa) => Data.Schematic.DSL.Representable ('Data.Schematic.Schema.SchemaArray cs sa) instance Data.Singletons.Internal.SingI cs => Data.Schematic.DSL.Representable ('Data.Schematic.Schema.SchemaText cs) instance Data.Singletons.Internal.SingI cs => Data.Schematic.DSL.Representable ('Data.Schematic.Schema.SchemaNumber cs) instance Data.Schematic.DSL.Representable 'Data.Schematic.Schema.SchemaBoolean instance Data.Singletons.Internal.SingI so => Data.Schematic.DSL.Representable ('Data.Schematic.Schema.SchemaOptional so) instance Data.Singletons.Internal.SingI (h : tl) => Data.Schematic.DSL.Representable ('Data.Schematic.Schema.SchemaUnion (h : tl)) module Data.Schematic.Migration data Path PKey :: Symbol -> Path PTraverse :: Path data Builder BKey :: Schema -> Symbol -> Builder -> Builder BTraverse :: Schema -> Builder -> Builder BScalar :: Schema -> Builder -- | Extracts revision/schema pairs from Versioned in reverse -- order. data Action AddKey :: Symbol -> Schema -> Action Update :: Schema -> Action DeleteKey :: Symbol -> Action -- | User-supplied atomic difference between schemas. Migrations can -- consists of many differences. data Diff Diff :: [Path] -> Action -> Diff -- | User-provided name of the revision. type Revision = Symbol data Migration Migration :: Revision -> [Diff] -> Migration data Versioned Versioned :: Schema -> [Migration] -> Versioned type DataMigration s m h = Tagged s (JsonRepr h -> m (JsonRepr s)) data MList :: (Type -> Type) -> [Schema] -> Type [MNil] :: (Monad m, SingI s, TopLevel s) => MList m '[s] [:&&] :: (TopLevel s, SingI s) => DataMigration s m h -> MList m (h : tl) -> MList m (s : h : tl) migrateObject :: forall m fs fh. (FSubset fs fs (FImage fs fs), Monad m) => (Rec (Tagged fs :. FieldRepr) fh -> m (Rec (Tagged fs :. FieldRepr) fs)) -> Tagged ( 'SchemaObject fs) (JsonRepr ( 'SchemaObject fh) -> m (JsonRepr ( 'SchemaObject fs))) shrinkObject :: forall rs ss m. (Monad m, FSubset rs ss (FImage rs ss)) => Tagged ( 'SchemaObject rs) (JsonRepr ( 'SchemaObject ss) -> m (JsonRepr ( 'SchemaObject rs))) type MigrationList m vs = MList m (MapSnd (AllVersions vs)) instance GHC.TypeLits.KnownSymbol s => Data.Singletons.Internal.SingI ('Data.Schematic.Migration.PKey s) instance Data.Singletons.Internal.SingI 'Data.Schematic.Migration.PTraverse module Data.Schematic decodeAndValidateJson :: forall schema. (FromJSON (JsonRepr schema), TopLevel schema, SingI schema) => ByteString -> ParseResult (JsonRepr schema) parseAndValidateJson :: forall schema. (FromJSON (JsonRepr schema), TopLevel schema, SingI schema) => Value -> ParseResult (JsonRepr schema) parseAndValidateJsonBy :: (FromJSON (JsonRepr schema), TopLevel schema, SingI schema) => proxy schema -> Value -> ParseResult (JsonRepr schema) parseAndValidateTopVersionJson :: forall proxy (v :: Versioned). (SingI (TopVersion (AllVersions v))) => proxy v -> Value -> ParseResult (JsonRepr (TopVersion (AllVersions v))) parseAndValidateWithMList :: Monad m => MList m revisions -> Value -> m (ParseResult (JsonRepr (Head revisions))) decodeAndValidateVersionedWithMList :: Monad m => proxy versioned -> MList m (MapSnd (AllVersions versioned)) -> ByteString -> m (ParseResult (JsonRepr (Head (MapSnd (AllVersions versioned))))) decodeAndValidateVersionedWithPureMList :: proxy versioned -> MList Identity (MapSnd (AllVersions versioned)) -> ByteString -> ParseResult (JsonRepr (Head (MapSnd (AllVersions versioned)))) isValid :: ParseResult a -> Bool isDecodingError :: ParseResult a -> Bool isValidationError :: ParseResult a -> Bool data ParseResult a Valid :: a -> ParseResult a DecodingError :: Text -> ParseResult a ValidationError :: ErrorMap -> ParseResult a withRepr :: Constructor a field :: forall fn. KnownSymbol fn => FieldConstructor fn