json-autotype-3.1.2: Automatic type declaration for JSON input data
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.AutoType.Nested

Description

Simple interface for using AutoType inference in other code generators.

Simply takes a list of Aeson values, and returns a type description.

For this type description, we can use function to generate an entire new module.

Note that while we can put more code in the module, it is recommended to avoid multiple automatically generated types in order to avoid name conflicts.

NOTE: this interface is yet unstable

Synopsis

Documentation

defaultImportedModules :: [ModuleImport] Source #

List of modules imported for Autotyped declarations

generateModuleImports :: [ModuleImport] -> Text Source #

Given a list of imports, generate source code.

inferType :: Text -> [Value] -> TypeFrag Source #

Given intended type name, and a list of text fields with JSON, return either an error, or an EndpointResponse that allows to declare and use this type in generated module.

data CodeFrag a Source #

Generated code reference and its requirements Content to embed in an autogenerated module:

  • name of the reference
  • declarations to describe it
  • module imports necessary for declarations to work

Constructors

CodeFrag 

Fields

Instances

Instances details
Default TypeFrag Source # 
Instance details

Defined in Data.Aeson.AutoType.Nested

Methods

def :: TypeFrag

Eq a => Eq (CodeFrag a) Source # 
Instance details

Defined in Data.Aeson.AutoType.Nested

Methods

(==) :: CodeFrag a -> CodeFrag a -> Bool #

(/=) :: CodeFrag a -> CodeFrag a -> Bool #

Show a => Show (CodeFrag a) Source # 
Instance details

Defined in Data.Aeson.AutoType.Nested

Methods

showsPrec :: Int -> CodeFrag a -> ShowS #

show :: CodeFrag a -> String #

showList :: [CodeFrag a] -> ShowS #

Generic (CodeFrag a) Source # 
Instance details

Defined in Data.Aeson.AutoType.Nested

Associated Types

type Rep (CodeFrag a) :: Type -> Type #

Methods

from :: CodeFrag a -> Rep (CodeFrag a) x #

to :: Rep (CodeFrag a) x -> CodeFrag a #

type Rep (CodeFrag a) Source # 
Instance details

Defined in Data.Aeson.AutoType.Nested

type Rep (CodeFrag a)

type ModuleImport = Text Source #

Alias for indicating that this is item in module imports list.