Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains functions for loading and decoding ModuleInterface
s
from TOML configuration files.
The module interface file contains the entries of a ModuleInterface
.
The file format is TOML (see https://github.com/toml-lang/toml).
JSON files can be decoded as well. The TOML format is preferred for
configuration files maintained by humans and JSON should be used to
read automatically generated (serialized) interfaces.
File contents
The TOML document is expected to contain four arrays of tables types
,
type-synonyms
, constructors
and functions
. Each table in these
arrays defines a data type, type synonym, constructor or function
respectively. The expected contents of each table is described below.
In addition, the module interface file contains meta information in the
top-level table.
Top-Level
The top-level table must contain the following key/value pairs:
version
(Integer
) the version of the configuration file format. The current version ismoduleInterfaceFileFormatVersion
. If there is a breaking change in the future, the module interface file format version should be updated. The parser accepts module interface files that use the most recent version only.module-name
(String
) the name of the module that is described by the module interface file.library-name
(String
) the name of the Coq library that contains the module.exported-types
(Array
ofString
) the names (haskell-name
) of the type-level entries exported by the module. All other entries in thetypes
andtype-synonyms
tables are "hidden" (i.e. cannot be used by an importing module directly).exported-values
(Array
ofString
) the names (haskell-name
) of the value-level entries exported by the module. All other entries in theconstructors
andfunctions
tables are "hidden" (i.e. cannot be used by an importing module directly).
Data types
The tables in the types
array must contain the following key/value pairs:
haskell-name
(String
) the qualified Haskell name of the type constructor in the module it has been defined in.coq-name
(String
) the identifier of the corresponding Coq type constructor.arity
(Integer
) the number of type arguments expected by the type constructor.cons-names
(Array
ofString
) the names of the constructors of the defined data type.
Type synonyms
The tables in the type-synonyms
array must contain the following
key/value pairs:
haskell-name
(String
) the qualified Haskell name of the type synonym in the module it has been defined in.coq-name
(String
) the identifier of the corresponding Coq definition.arity
(Integer
) the number of type arguments expected by the type synonym.haskell-type
(String
) the Haskell type that is abbreviated by the type synonym.type-arguments
(Array
ofString
) the Haskell identifiers of the type arguments. Must be of lengtharity
.
Constructors
The tables in the constructors
array must contain the following
key/value pairs:
haskell-type
(String
) the Haskell type of the data constructor.haskell-name
(String
) the qualified Haskell name of the data constructor in the module it has been defined in.coq-name
(String
) the identifier of the corresponding Coq data constructor.coq-smart-name
(String
) the identifier of the corresponding Coq smart constructor.arity
(Integer
) the number of arguments expected by the data constructor.
Functions
The tables in the functions
array must contain the following
key/value pairs:
haskell-type
(String
) the Haskell type of the function.haskell-name
(String
) the qualified Haskell name of the function in the module it has been defined in.coq-name
(String
) the identifier of the corresponding Coq function.arity
(Integer
) the number of arguments expected by the function.strict-args
(Array
ofBoolean
) whether the function is strict in in its arguments.effects
(Array
ofString
) the effects contained in the function, i.e. which type classes need to be passed.needs-free-args
(Boolean
) whether the arguments of theFree
monad need to be passed to the function.
Additionally, the following optional key/value pairs are allowed.
encapsulates-effects
(Boolean
, defaults tofalse
) whether the function encapsulates effects. This property should only be set totrue
for selected functions from the base library. For example, the flag is set for functions from the QuickCheck extension.
Synopsis
- loadModuleInterface :: (MonadIO r, MonadReporter r) => FilePath -> r ModuleInterface
Documentation
loadModuleInterface :: (MonadIO r, MonadReporter r) => FilePath -> r ModuleInterface Source #
Loads a module interface file from a .toml
or .json
file.
Orphan instances
FromJSON Qualid Source # | Restores a Coq identifier from the interface file. |
parseJSON :: Value -> Parser Qualid parseJSONList :: Value -> Parser [Qualid] | |
FromJSON Effect Source # | Restores an effect from the interface file. |
parseJSON :: Value -> Parser Effect parseJSONList :: Value -> Parser [Effect] | |
FromJSON QName Source # | All Haskell names in the interface file are qualified. |
parseJSON :: Value -> Parser QName parseJSONList :: Value -> Parser [QName] | |
FromJSON Type Source # | Restores a Haskell type from the interface file. |
parseJSON :: Value -> Parser Type parseJSONList :: Value -> Parser [Type] | |
FromJSON QName Source # | |
parseJSON :: Value -> Parser QName parseJSONList :: Value -> Parser [QName] | |
FromJSON ModuleInterface Source # | Restores a |
parseJSON :: Value -> Parser ModuleInterface parseJSONList :: Value -> Parser [ModuleInterface] |