hydra.haskell.coder module
Functions for encoding Hydra modules as Haskell modules.
- hydra.haskell.coder.adapt_type_to_haskell_and_encode(namespaces: ModuleNames[ModuleName], typ: Type, cx: T0, g: T1) object
Adapt a Hydra type to Haskell’s type system and encode it.
- hydra.haskell.coder.constant_for_field_name(tname: Name, fname: Name) str
Generate a constant name for a field (e.g., ‘_TypeName_fieldName’).
- hydra.haskell.coder.constant_for_type_name(tname: Name) str
Generate a constant name for a type (e.g., ‘_TypeName’).
- hydra.haskell.coder.construct_module(overlay_subs: Set[str], namespaces: ModuleNames[ModuleName], mod: Module, defs: Sequence[Definition], cx: T0, g: Graph) object
Construct a Haskell module from a Hydra module and its definitions.
- hydra.haskell.coder.encode_case_expression(depth: int, namespaces: ModuleNames[ModuleName], stmt: CaseStatement, scrutinee: Expression, cx: T0, g: Graph) object
Encode a Hydra case statement as a Haskell case expression with a given scrutinee.
- hydra.haskell.coder.encode_lambda_term(depth: int, namespaces: ModuleNames[ModuleName], lam: Lambda, cx: T0, g: Graph) object
Encode a Hydra lambda as a Haskell expression.
- hydra.haskell.coder.encode_literal(l: Literal, cx: T0) object
Encode a Hydra literal as a Haskell expression.
- hydra.haskell.coder.encode_projection(namespaces: ModuleNames[ModuleName], proj: Projection) object
Encode a record projection as a Haskell expression.
- hydra.haskell.coder.encode_standalone_cases(depth: int, namespaces: ModuleNames[ModuleName], stmt: CaseStatement, cx: T0, g: Graph) object
Encode a standalone (un-applied) case statement as a Haskell lambda over a case expression.
- hydra.haskell.coder.encode_term(depth: int, namespaces: ModuleNames[ModuleName], term: Term, cx: T0, g: Graph) object
Encode a Hydra term as a Haskell expression.
- hydra.haskell.coder.encode_type(namespaces: ModuleNames[ModuleName], typ: Type, cx: T0, g: T1) object
Encode a Hydra type as a Haskell type.
- hydra.haskell.coder.encode_type_with_class_assertions(namespaces: ModuleNames[ModuleName], explicit_classes: Mapping[Name, Set[Name]], typ: Type, cx: T0, g: T1) object
Encode a Hydra type as a Haskell type with typeclass assertions.
- hydra.haskell.coder.encode_unwrap(namespaces: ModuleNames[ModuleName], name: Name) object
Encode an unwrap term as a Haskell expression.
- hydra.haskell.coder.extend_meta_for_term(meta: HaskellModuleMetadata, term: Term) HaskellModuleMetadata
Extend metadata by analyzing a term for standard import usage (bottom-up step function).
- hydra.haskell.coder.extend_meta_for_type(meta: HaskellModuleMetadata, typ: Type) HaskellModuleMetadata
Extend metadata by analyzing a type for standard import usage (bottom-up step function).
- hydra.haskell.coder.find_ord_variables(typ: Type) Set[Name]
Find type variables that require an Ord constraint (used in maps or sets).
- hydra.haskell.coder.gather_metadata(defs: Sequence[Definition]) HaskellModuleMetadata
Gather metadata from definitions by bottom-up traversal of all terms and types.
- hydra.haskell.coder.get_implicit_type_classes(typ: Type) Mapping[Name, Set[Name]]
Get implicit typeclass constraints for type variables that need Ord.
- hydra.haskell.coder.module_to_haskell(overlay_subs: Set[str], mod: Module, defs: Sequence[Definition], cx: T0, g: Graph) object
Convert a Hydra module to Haskell source code as a filepath-to-content map.
- hydra.haskell.coder.module_to_haskell_module(overlay_subs: Set[str], mod: Module, defs: Sequence[Definition], cx: T0, g: Graph) object
Convert a Hydra module and definitions to a Haskell module AST.
- hydra.haskell.coder.name_decls(namespaces: ModuleNames[ModuleName], name: Name, typ: Type) Sequence[Declaration]
Generate Haskell declarations for type and field name constants.
- hydra.haskell.coder.set_meta_uses_byte_string(b: bool, m: HaskellModuleMetadata) HaskellModuleMetadata
Set the usesByteString flag in Haskell module metadata.
- hydra.haskell.coder.set_meta_uses_int(b: bool, m: HaskellModuleMetadata) HaskellModuleMetadata
Set the usesInt flag in Haskell module metadata.
- hydra.haskell.coder.set_meta_uses_map(b: bool, m: HaskellModuleMetadata) HaskellModuleMetadata
Set the usesMap flag in Haskell module metadata.
- hydra.haskell.coder.set_meta_uses_set(b: bool, m: HaskellModuleMetadata) HaskellModuleMetadata
Set the usesSet flag in Haskell module metadata.
- hydra.haskell.coder.set_meta_uses_void(b: bool, m: HaskellModuleMetadata) HaskellModuleMetadata
Set the usesVoid flag in Haskell module metadata.
- hydra.haskell.coder.to_data_declaration(namespaces: ModuleNames[ModuleName], def_: TermDefinition, cx: T0, g: Graph) object
Convert a Hydra term definition to a Haskell declaration with comments.
- hydra.haskell.coder.to_type_declarations_from(namespaces: ModuleNames[ModuleName], element_name: Name, typ: Type, cx: T0, g: Graph) object
Convert a Hydra type definition to Haskell declarations.
- hydra.haskell.coder.type_decl(namespaces: ModuleNames[ModuleName], name: Name, typ: Type, cx: T0, g: Graph) object
Generate a Haskell declaration for a type definition constant.
- hydra.haskell.coder.type_scheme_constraints_to_class_map(constraints: Mapping[T0, TypeVariableConstraints]) Mapping[T0, Set[Name]]
Project type scheme constraints to a map of type variables to typeclass names.