-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Automatic type declaration for JSON input data -- -- Generates datatype declarations with Aeson's FromJSON instances -- from a set of example ".json" files. -- -- To get started you need to install the package, and run -- "json-autotype" binary on an input ".json" file. That will generate a -- new Aeson-based JSON parser. -- -- "$ json-autotype input.json -o JSONTypes.hs" -- -- Feel free to tweak the by changing types of the fields - any field -- type that is instance of FromJSON should work. -- -- You may immediately test the parser by calling it as a script: -- -- "$ runghc JSONTypes.hs input.json" -- -- See introduction on https://github.com/mgajda/json-autotype for -- details. @package json-autotype @version 0.4 -- | Module implementing loading generic plugins using Hint. module Data.Aeson.AutoType.Plugin.Loader -- | Imports a set of plugin modules with the same "interface" value, and -- returns values exported as their interfaces. -- -- Arguments: * argument name exported from each module as an interface, -- * list of plugin modules (given as either module paths or file paths). -- -- Result: * Result is a list of exported objects in the order of module -- names. importPlugins :: Typeable a => String -> [FilePath] -> IO [a] -- | Test script main :: IO () -- | This module defines data type (a :|: b) that behaves all like -- Either, except that has no tag in JSON representation as used -- by FromJSON and ToJSON. module Data.Aeson.AutoType.Alternative -- | Data type (a :|: b) that behaves all like Either, except that -- has no tag in JSON representation as used by FromJSON and -- ToJSON. data (:|:) a b [AltLeft] :: a -> (:|:) a b [AltRight] :: b -> (:|:) a b -- | Convert to Either datatype. toEither :: a :|: b -> Either a b -- | Convert from Either datatype. fromEither :: Either a b -> a :|: b -- | Deconstruct the type with two functions corresponding to constructors. -- This is like either. alt :: (a -> c) -> (b -> c) -> a :|: b -> c instance (Ord a, Ord b) => Ord (a :|: b) instance (Eq a, Eq b) => Eq (a :|: b) instance (Show a, Show b) => Show (a :|: b) instance (ToJSON a, ToJSON b) => ToJSON (a :|: b) instance (FromJSON a, FromJSON b) => FromJSON (a :|: b) -- | Instances of Text.PrettyPrint.Out class to visualize Aeson -- Value data structure. module Data.Aeson.AutoType.Pretty instance Constructor C1_5Value instance Constructor C1_4Value instance Constructor C1_3Value instance Constructor C1_2Value instance Constructor C1_1Value instance Constructor C1_0Value instance Datatype D1Value instance Generic Value instance Out Scientific instance Out a => Out (Vector a) instance Out Value instance Out a => Out (Set a) instance (Out a, Out b) => Out (HashMap a b) instance Out Text -- | Union types describing JSON objects, and operations for querying these -- types. module Data.Aeson.AutoType.Type -- | Size of the Type term. typeSize :: Type -> Int -- | Dictionary of types indexed by names. newtype Dict [Dict] :: Map Text Type -> Dict [unDict] :: Dict -> Map Text Type -- | Take all keys from dictionary. keys :: Dict -> Set Text -- | Lookup the Type within the dictionary. get :: Text -> Dict -> Type -- | Make operation on a map to an operation on a Dict. withDict :: (Map Text Type -> Map Text Type) -> Dict -> Dict -- | Union types for JSON values. data Type [TNull] :: Type [TBool] :: Type [TNum] :: Type [TString] :: Type [TUnion] :: (Set Type) -> Type [TLabel] :: Text -> Type [TObj] :: Dict -> Type [TArray] :: Type -> Type -- | Empty type emptyType :: Type -- | Is it a simple (non-compound) Type? isSimple :: Type -> Bool -- | Is the top-level constructor a TArray? | Check if the given type has -- non-top TObj. isArray :: Type -> Bool -- | Is the top-level constructor a TObj? isObject :: Type -> Bool -- | Convert any type into union type (even if just singleton). typeAsSet :: Type -> Set Type -- | Check if the given type has non-top TObj. hasNonTopTObj :: Type -> Bool -- | Check if the given type has TObj on top or within array.. hasTObj :: Type -> Bool -- | Check if this is nullable (Maybe) type, or not. Nullable type will -- always accept TNull or missing key that contains it. isNullable :: Type -> Bool -- | Null-ish types emptySetLikes :: Set Type instance Selector S1_0_0Dict instance Constructor C1_0Dict instance Datatype D1Dict instance Constructor C1_7Type instance Constructor C1_6Type instance Constructor C1_5Type instance Constructor C1_4Type instance Constructor C1_3Type instance Constructor C1_2Type instance Constructor C1_1Type instance Constructor C1_0Type instance Datatype D1Type instance Generic Dict instance Data Dict instance Eq Dict instance Generic Type instance Data Type instance Ord Type instance Eq Type instance Show Type instance Out Dict instance Show Dict instance Ord Dict instance Out Type instance Uniplate Type -- | Extraction and unification of AutoType's Type from Aeson -- Value. module Data.Aeson.AutoType.Extract -- | Compute total number of nodes (and leaves) within the value tree. Each -- simple JavaScript type (including String) is counted as of size 1, -- whereas both Array or object types are counted as 1+sum of the sizes -- of their member values. valueSize :: Value -> Int -- | Compute total size of the type of the Value. For: * simple -- types it is always 1, * for arrays it is just 1+_maximum_ size of the -- (single) element type, * for objects it is _sum_ of the sizes of -- fields (since each field type is assumed to be different.) valueTypeSize :: Value -> Int -- | Compute total depth of the value. For: * simple types it is 1 * for -- either Array or Object, it is 1 + maximum of depths of their members valueDepth :: Value -> Int -- | Dictionary of types indexed by names. newtype Dict [Dict] :: Map Text Type -> Dict [unDict] :: Dict -> Map Text Type -- | Union types for JSON values. data Type [TNull] :: Type [TBool] :: Type [TNum] :: Type [TString] :: Type [TUnion] :: (Set Type) -> Type [TLabel] :: Text -> Type [TObj] :: Dict -> Type [TArray] :: Type -> Type -- | Empty type emptyType :: Type -- | Extract Type from the JSON Value. Unifying types of -- array elements, if necessary. extractType :: Value -> Type -- | Standard unification procedure on Types, with inclusion of -- Type unions. unifyTypes :: Type -> Type -> Type -- | Type check the value with the derived type. typeCheck :: Value -> Type -> Bool -- | Formatting type declarations and class instances for inferred types. module Data.Aeson.AutoType.Format -- | Display an environment of types split by name. displaySplitTypes :: Map Text Type -> Text -- | Splits initial type with a given label, into a mapping of object type -- names and object type structures. splitTypeByLabel :: Text -> Type -> Map Text Type -- | For a given splitted types, it returns candidates for extra -- unifications. unificationCandidates :: HashMap t Type -> [[t]] -- | Unifies candidates on a give input list. unifyCandidates :: [[Text]] -> Map Text Type -> Map Text Type instance Selector S1_0_1DeclState instance Selector S1_0_0DeclState instance Constructor C1_0DeclState instance Datatype D1DeclState instance Generic DeclState instance Ord DeclState instance Show DeclState instance Eq DeclState -- | Wrappers for generating prologue and epilogue code in Haskell. module Data.Aeson.AutoType.CodeGen -- | Write a Haskell module to an output file, or stdout if - -- filename is given. writeHaskellModule :: FilePath -> HashMap Text Type -> IO () -- | Default output filname is used, when there is no explicit output file -- path, or it is "-" (stdout). Default module name is consistent with -- it. defaultOutputFilename :: FilePath -- | API to which SubtypePlugins should conform. module Data.Aeson.AutoType.Plugin.Subtype -- | Operations that SubtypPlugin must implement. data SubtypePlugin [SubtypePlugin] :: ([Value] -> Maybe SubtypeDesc) -> (SubtypeDesc -> SubtypeDesc -> Either SubtypeDesc Type) -> SubtypePlugin [detect] :: SubtypePlugin -> [Value] -> Maybe SubtypeDesc -- | Check whether a set of values belongs to this type family [unify] :: SubtypePlugin -> SubtypeDesc -> SubtypeDesc -> Either SubtypeDesc Type -- | Description of a subtype data SubtypeDesc [SubtypeDesc] :: String -> Type -> (String -> String) -> String -> Dynamic -> SubtypeDesc [subtypeName] :: SubtypeDesc -> String -- | Code that is different for different type families [subtypeClass] :: SubtypeDesc -> Type [reference] :: SubtypeDesc -> String -> String -- | Show type reference with a given name prefix [declare] :: SubtypeDesc -> String -- | Show type declaration [typeInfo] :: SubtypeDesc -> Dynamic