-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | JSON-biased spec and validation tool -- -- JSON-biased spec and validation tool @package schematic @version 0.2.0.0 module Data.Schematic.Utils class Known a known :: Known a => a data Dict c [Dict] :: c => Dict c instance forall k (a :: k). Data.Schematic.Utils.Known (Data.Proxy.Proxy a) instance GHC.TypeLits.KnownNat n => Data.Schematic.Utils.Known (Data.Singletons.Sing n) instance GHC.TypeLits.KnownSymbol s => Data.Schematic.Utils.Known (Data.Singletons.Sing s) instance forall k k1 (a :: k1) (b :: k). (Data.Schematic.Utils.Known (Data.Singletons.Sing a), Data.Schematic.Utils.Known (Data.Singletons.Sing b)) => Data.Schematic.Utils.Known (Data.Singletons.Sing '(a, b)) instance Data.Schematic.Utils.Known (Data.Singletons.Sing '[]) instance forall a (a1 :: a) (as :: [a]). (Data.Schematic.Utils.Known (Data.Singletons.Sing a1), Data.Schematic.Utils.Known (Data.Singletons.Sing as)) => Data.Schematic.Utils.Known (Data.Singletons.Sing (a1 : as)) instance Data.Schematic.Utils.Known (Data.Vinyl.Core.Rec Data.Singletons.Sing '[]) instance forall u (a :: u) (tl :: [u]). (Data.Schematic.Utils.Known (Data.Singletons.Sing a), Data.Schematic.Utils.Known (Data.Vinyl.Core.Rec Data.Singletons.Sing tl)) => Data.Schematic.Utils.Known (Data.Vinyl.Core.Rec Data.Singletons.Sing (a : tl)) instance c => Data.Schematic.Utils.Known (Data.Schematic.Utils.Dict c) 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 instance (GHC.TypeLits.KnownSymbol k, Data.Schematic.Utils.Known (Data.Singletons.Sing k)) => Data.Schematic.Utils.Known (Data.Singletons.Sing ('Data.Schematic.Path.Key k)) instance (GHC.TypeLits.KnownNat n, Data.Schematic.Utils.Known (Data.Singletons.Sing n)) => Data.Schematic.Utils.Known (Data.Singletons.Sing ('Data.Schematic.Path.Ix n)) module Data.Schematic.Instances instance forall u (m :: * -> *) (f :: u -> GHC.Types.*). GHC.Base.Monad m => Test.SmallCheck.Series.Serial m (Data.Vinyl.Core.Rec f '[]) instance forall a (m :: * -> *) (f :: a -> *) (a1 :: a) (as :: [a]). (Test.SmallCheck.Series.Serial m (f a1), 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 (a1 : 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 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 data DemotedSchema DSchemaText :: [DemotedTextConstraint] -> DemotedSchema DSchemaNumber :: [DemotedNumberConstraint] -> DemotedSchema DSchemaBoolean :: DemotedSchema DSchemaObject :: [(Text, DemotedSchema)] -> DemotedSchema DSchemaArray :: [DemotedArrayConstraint] -> DemotedSchema -> DemotedSchema DSchemaNull :: DemotedSchema DSchemaOptional :: 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) fromOptional :: SingI s => Sing (SchemaOptional s) -> Value -> Parser (Maybe (JsonRepr s)) class FalseConstraint a instance GHC.Generics.Generic Data.Schematic.Schema.DemotedSchema instance GHC.Generics.Generic Data.Schematic.Schema.Schema instance GHC.Generics.Generic Data.Schematic.Schema.DemotedArrayConstraint instance GHC.Generics.Generic Data.Schematic.Schema.ArrayConstraint instance GHC.Generics.Generic Data.Schematic.Schema.DemotedNumberConstraint instance GHC.Generics.Generic Data.Schematic.Schema.NumberConstraint 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 Data.Singletons.SingKind Data.Schematic.Schema.TextConstraint instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.TEq n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.TGt n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.TGe n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.TLt n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.TLe n) instance (GHC.TypeLits.KnownSymbol s, Data.Singletons.SingI s) => Data.Singletons.SingI ('Data.Schematic.Schema.TRegex s) instance Data.Singletons.SingI ss => Data.Singletons.SingI ('Data.Schematic.Schema.TEnum ss) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.TEq n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.TLt n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.TLe n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.TGt n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.TGe n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.TRegex t)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.TEnum ss)) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.NEq n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.NGt n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.NGe n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.NLt n) instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.NLe n) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.NEq n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.NLt n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.NLe n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.NGt n)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.NGe n)) instance Data.Singletons.SingKind Data.Schematic.Schema.NumberConstraint instance GHC.TypeLits.KnownNat n => Data.Singletons.SingI ('Data.Schematic.Schema.AEq n) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.AEq n)) instance Data.Singletons.SingKind Data.Schematic.Schema.ArrayConstraint instance Data.Singletons.SingI sl => Data.Singletons.SingI ('Data.Schematic.Schema.SchemaText sl) instance Data.Singletons.SingI sl => Data.Singletons.SingI ('Data.Schematic.Schema.SchemaNumber sl) instance Data.Singletons.SingI 'Data.Schematic.Schema.SchemaNull instance Data.Singletons.SingI 'Data.Schematic.Schema.SchemaBoolean instance (Data.Singletons.SingI ac, Data.Singletons.SingI s) => Data.Singletons.SingI ('Data.Schematic.Schema.SchemaArray ac s) instance Data.Singletons.SingI stl => Data.Singletons.SingI ('Data.Schematic.Schema.SchemaObject stl) instance Data.Singletons.SingI s => Data.Singletons.SingI ('Data.Schematic.Schema.SchemaOptional s) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.SchemaText cs)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.SchemaNumber cs)) instance GHC.Classes.Eq (Data.Singletons.Sing 'Data.Schematic.Schema.SchemaNull) instance GHC.Classes.Eq (Data.Singletons.Sing 'Data.Schematic.Schema.SchemaBoolean) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.SchemaArray as s)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.SchemaObject cs)) instance GHC.Classes.Eq (Data.Singletons.Sing ('Data.Schematic.Schema.SchemaOptional s)) instance Data.Singletons.SingKind Data.Schematic.Schema.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.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.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.Base.Monad m, Test.SmallCheck.Series.Serial m Data.Text.Internal.Text) => 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) => 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.Vector.Vector (Data.Schematic.Schema.JsonRepr s)) => 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.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 Data.Singletons.SingI schema => Data.Aeson.Types.FromJSON.FromJSON (Data.Schematic.Schema.JsonRepr schema) instance Data.Aeson.Types.ToJSON.ToJSON (Data.Schematic.Schema.JsonRepr a) module Data.Schematic.JsonSchema toJsonSchema :: forall proxy schema. SingI schema => proxy (schema :: Schema) -> Schema toJsonSchema' :: DemotedSchema -> Schema 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 ByRevision fn rs i :: Schema where { type family ByRevision fn rs i :: Schema; } flens :: (FElem fn rs i, Functor g) => proxy fn -> (FieldRepr '(fn, ByRevision fn rs i) -> g (FieldRepr '(fn, ByRevision fn rs i))) -> Rec FieldRepr rs -> g (Rec FieldRepr rs) -- | For Vinyl users who are not using the lens package, we -- provide a getter. fget :: FElem fn rs i => proxy fn -> Rec FieldRepr rs -> FieldRepr '(fn, ByRevision fn 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 => FieldRepr '(fn, ByRevision fn rs i) -> Rec FieldRepr rs -> Rec FieldRepr rs 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.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 data MList :: (* -> *) -> [Schema] -> Type [MNil] :: (Monad m, SingI s, TopLevel s) => MList m '[s] [:&&] :: (TopLevel s, SingI s) => proxy s -> (JsonRepr h -> m (JsonRepr s)) -> MList m (h : tl) -> MList m (s : (h : tl)) instance GHC.TypeLits.KnownSymbol s => Data.Singletons.SingI ('Data.Schematic.Migration.PKey s) instance Data.Singletons.SingI 'Data.Schematic.Migration.PTraverse 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 () 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) 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))))) 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