json-to-type-4.0.0: Automatic type declaration for JSON input data
Safe HaskellSafe-Inferred
LanguageHaskell2010

JsonToType.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 JsonToType.Nested

Methods

def :: TypeFrag #

Generic (CodeFrag a) Source # 
Instance details

Defined in JsonToType.Nested

Associated Types

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

Methods

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

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

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

Defined in JsonToType.Nested

Methods

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

show :: CodeFrag a -> String #

showList :: [CodeFrag a] -> ShowS #

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

Defined in JsonToType.Nested

Methods

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

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

type Rep (CodeFrag a) Source # 
Instance details

Defined in JsonToType.Nested

type Rep (CodeFrag a)

type ModuleImport = Text Source #

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