-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Types and type classes for defining JSON schemas. -- @package json-schema @version 0.6.1 -- | Types for defining JSON schemas. module Data.JSON.Schema.Types -- | Class representing JSON schemas class JSONSchema a schema :: JSONSchema a => Proxy a -> Schema -- | A schema for a JSON value. data Schema -- | A choice of multiple values, e.g. for sum types. Choice :: [Schema] -> Schema -- | A JSON object. Object :: [Field] -> Schema -- | A JSON object with arbitrary keys. Map :: Schema -> Schema -- | An array. The LengthBound represent the lower and upper bound of the -- array size. The value unboundedLength indicates no bound. The -- boolean denotes whether items have to be unique. Array :: LengthBound -> Bool -> Schema -> Schema -- | A fixed-length tuple of different values. Tuple :: [Schema] -> Schema -- | A string. The LengthBound denote the lower and upper bound of the -- length of the string. The value unboundedLength indicates no -- bound. Value :: LengthBound -> Schema -- | A Bool. Boolean :: Schema -- | A number. The Bound denote the lower and upper bound on the value. The -- value unbounded indicates no bound. Number :: Bound -> Schema -- | A Value that never changes. Can be combined with Choice to create -- enumerables. Constant :: Value -> Schema -- | Only null is allowed. Null :: Schema -- | Anything value is allowed. Any :: Schema -- | A field in an object. data Field Field :: Text -> Bool -> Schema -> Field key :: Field -> Text required :: Field -> Bool content :: Field -> Schema -- | A type for bounds on number domains. Use Nothing when no lower or -- upper bound makes sense data Bound Bound :: Maybe Int -> Maybe Int -> Bound lower :: Bound -> Maybe Int upper :: Bound -> Maybe Int -- | A type for bounds on lengths for strings and arrays. Use Nothing when -- no lower or upper bound makes sense data LengthBound LengthBound :: Maybe Int -> Maybe Int -> LengthBound lowerLength :: LengthBound -> Maybe Int upperLength :: LengthBound -> Maybe Int unbounded :: Bound unboundedLength :: LengthBound instance Eq Bound instance Show Bound instance Eq LengthBound instance Show LengthBound instance Eq Field instance Show Field instance Eq Schema instance Show Schema instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l, JSONSchema m, JSONSchema n, JSONSchema o) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l, JSONSchema m, JSONSchema n) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l, m, n) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l, JSONSchema m) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l, m) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k, JSONSchema l) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k, l) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j, JSONSchema k) => JSONSchema (a, b, c, d, e, f, g, h, i, j, k) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i, JSONSchema j) => JSONSchema (a, b, c, d, e, f, g, h, i, j) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h, JSONSchema i) => JSONSchema (a, b, c, d, e, f, g, h, i) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g, JSONSchema h) => JSONSchema (a, b, c, d, e, f, g, h) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f, JSONSchema g) => JSONSchema (a, b, c, d, e, f, g) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e, JSONSchema f) => JSONSchema (a, b, c, d, e, f) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d, JSONSchema e) => JSONSchema (a, b, c, d, e) instance (JSONSchema a, JSONSchema b, JSONSchema c, JSONSchema d) => JSONSchema (a, b, c, d) instance (JSONSchema a, JSONSchema b, JSONSchema c) => JSONSchema (a, b, c) instance (JSONSchema a, JSONSchema b) => JSONSchema (a, b) instance JSONSchema a => JSONSchema (Set a) instance JSONSchema UTCTime instance (IsString k, JSONSchema v) => JSONSchema (HashMap k v) instance (IsString k, JSONSchema v) => JSONSchema (Map k v) instance JSONSchema a => JSONSchema (Vector a) instance JSONSchema a => JSONSchema [a] instance JSONSchema a => JSONSchema (Maybe a) instance JSONSchema Text instance JSONSchema Text instance JSONSchema Bool instance JSONSchema Word32 instance JSONSchema Integer instance JSONSchema Int instance JSONSchema () -- | Combinators for creating JSON schemas. module Data.JSON.Schema.Combinators -- | A schema combinator. type SchemaC = Schema -> Schema -- | Optionality operator for schemas. (<|>) :: Schema -> Schema -> Schema -- | Tupling. (<+>) :: Schema -> Schema -> Schema -- | If passed two objects, merges the fields. Otherwise creates a tuple. merge :: Schema -> Schema -> Schema -- | Create an object with a single field. field :: Text -> Bool -> Schema -> Schema -- | An unbounded string. value :: Schema -- | An unbounded number. number :: Schema -- | An unbounded array with non-unique values. array :: Schema -> Schema -- | Add a field to an object, or tuple if passed a non-object. addField :: Text -> Bool -> Schema -> SchemaC -- | Add multiple fields to an object, or tuple if passed a non-object. addFields :: [(Text, Bool, Schema)] -> SchemaC -- | An empty object. empty :: Schema -- | A choice between constant values. enum :: [Value] -> Schema unbounded :: Bound unboundedLength :: LengthBound -- | Generic derivation of schemas. The schemas generated match the JSON -- generated by type 'generic-aeson' package. See that package for -- documentation on the format and examples of it. module Data.JSON.Schema.Generic -- | Derive a JSON schema for types with an instance of Generic. gSchema :: (Generic a, GJSONSCHEMA (Rep a), ConNames (Rep a), GIsEnum (Rep a)) => Proxy a -> Schema instance [overlap ok] (Selector c, GJSONSCHEMA f) => GJSONSCHEMA (M1 S c f) instance [overlap ok] Selector c => GJSONSCHEMA (M1 S c (K1 i (Maybe String))) instance [overlap ok] (Selector c, JSONSchema a) => GJSONSCHEMA (M1 S c (K1 i (Maybe a))) instance [overlap ok] GJSONSCHEMA f => GJSONSCHEMA (M1 D c f) instance [overlap ok] (Constructor c, GJSONSCHEMA f) => GJSONSCHEMA (M1 C c f) instance [overlap ok] (GJSONSCHEMA f, GJSONSCHEMA g) => GJSONSCHEMA (f :*: g) instance [overlap ok] (GJSONSCHEMA f, GJSONSCHEMA g) => GJSONSCHEMA (f :+: g) instance [overlap ok] GJSONSCHEMA U1 instance [overlap ok] GJSONSCHEMA (K1 i String) instance [overlap ok] JSONSchema c => GJSONSCHEMA (K1 i c) module Data.JSON.Schema -- | A concrete, poly-kinded proxy type data Proxy (t :: k) :: k -> * Proxy :: Proxy