-- 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.4 -- | Types for defining JSON schemas. module Data.JSON.Schema.Types -- | A schema is any JSON value. type Schema = Value -- | A schema for a JSON value. data Value -- | A choice of multiple values, e.g. for sum types. Choice :: [Value] -> Value -- | A JSON object. Object :: [Field] -> Value -- | An array. The integers represent the lower and upper bound of the -- array size. The value -1 indicates no bound. The boolean denotes -- whether items have to unique. Array :: Int -> Int -> Bool -> Value -> Value -- | A fixed-length tuple of different values. Tuple :: [Value] -> Value -- | A string. The integers denote the lower and upper bound of the length -- of the string. The value -1 indicates no bound. Value :: Int -> Int -> Value Boolean :: Value -- | A number. The integers denote the lower and upper bound on the value. -- The value -1 indicates no bound. Number :: Int -> Int -> Value Null :: Value -- | A field in an object. data Field Field :: String -> Bool -> Schema -> Field key :: Field -> String required :: Field -> Bool content :: Field -> Schema -- | Class representing JSON schemas class JSONSchema a schema :: JSONSchema a => Proxy a -> Schema instance Eq Field instance Show Field instance Eq Value instance Show Value instance JSONSchema a => JSONSchema [a] instance JSONSchema a => JSONSchema (Maybe a) 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 :: String -> 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 :: String -> Bool -> Schema -> SchemaC -- | Add multiple fields to an object, or tuple if passed a non-object. addFields :: [(String, Bool, Schema)] -> SchemaC -- | An empty object. empty :: Schema -- | 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