content: module Hydra.Sources.Kernel.Terms.Constants where
  
  -- Standard imports for term-level kernel modules
  import Hydra.Kernel
  import Hydra.Sources.Libraries
  import qualified Hydra.Dsl.Accessors     as Accessors
  import qualified Hydra.Dsl.Ast           as Ast
  import qualified Hydra.Dsl.Coders        as Coders
  import qualified Hydra.Dsl.Compute       as Compute
  import qualified Hydra.Dsl.Core          as Core
  import qualified Hydra.Dsl.Grammar       as Grammar
  import qualified Hydra.Dsl.Graph         as Graph
  import qualified Hydra.Dsl.Json          as Json
  import qualified Hydra.Dsl.Lib.Chars     as Chars
  import qualified Hydra.Dsl.Lib.Equality  as Equality
  import qualified Hydra.Dsl.Lib.Flows     as Flows
  import qualified Hydra.Dsl.Lib.Lists     as Lists
  import qualified Hydra.Dsl.Lib.Literals  as Literals
  import qualified Hydra.Dsl.Lib.Logic     as Logic
  import qualified Hydra.Dsl.Lib.Maps      as Maps
  import qualified Hydra.Dsl.Lib.Math      as Math
  import qualified Hydra.Dsl.Lib.Optionals as Optionals
  import           Hydra.Dsl.Phantoms      as Phantoms
  import qualified Hydra.Dsl.Lib.Sets      as Sets
  import           Hydra.Dsl.Lib.Strings   as Strings
  import qualified Hydra.Dsl.Mantle        as Mantle
  import qualified Hydra.Dsl.Module        as Module
  import qualified Hydra.Dsl.TTerms        as TTerms
  import qualified Hydra.Dsl.TTypes        as TTypes
  import qualified Hydra.Dsl.Terms         as Terms
  import qualified Hydra.Dsl.Topology      as Topology
  import qualified Hydra.Dsl.Types         as Types
  import qualified Hydra.Dsl.Typing        as Typing
  import           Hydra.Sources.Kernel.Types.All
  import           Prelude hiding ((++))
  import qualified Data.Int                as I
  import qualified Data.List               as L
  import qualified Data.Map                as M
  import qualified Data.Set                as S
  import qualified Data.Maybe              as Y
  
  
  module_ :: Module
  module_ = Module (Namespace "hydra.constants") elements
      []
      kernelTypesModules $
      Just ("A module for tier-0 constants.")
    where
     elements = [
       el debugInferenceDef,
       el ignoredVariableDef,
       el key_classesDef,
       el key_debugIdDef,
       el key_deprecatedDef,
       el key_descriptionDef,
       el key_excludeDef,
       el key_firstClassTypeDef,
       el key_maxLengthDef,
       el key_minLengthDef,
       el key_preserveFieldNameDef,
       el key_typeDef,
       el key_freshTypeVariableCountDef,
       el maxInt32Def,
       el placeholderNameDef,
       el maxTraceDepthDef,
       el warningAutoGeneratedFileDef]
  
  define :: String -> TTerm a -> TBinding a
  define = definitionInModule module_
  
  defineAnnotationKey :: String -> Maybe String -> TBinding Name
  defineAnnotationKey name mdesc = define ("key_" <> name) $ case mdesc of
      Nothing -> def
      Just comment -> doc comment def
    where
      def = wrap _Name $ string name
  
  -- 
  
  debugInferenceDef :: TBinding Bool
  debugInferenceDef = define "debugInference" $
    doc "Disable type checking by default, for better performance" $
    true
    
  ignoredVariableDef :: TBinding String
  ignoredVariableDef = define "ignoredVariable" $
    string "_"
  
  key_classesDef = defineAnnotationKey "classes" Nothing
  key_debugIdDef = defineAnnotationKey "debugId" Nothing
  key_deprecatedDef = defineAnnotationKey "deprecated" Nothing
  key_descriptionDef = defineAnnotationKey "description" Nothing
  key_excludeDef = defineAnnotationKey "exclude" Nothing
  key_firstClassTypeDef = defineAnnotationKey "firstClassType" $
    Just "A flag which tells the language coders to encode a given encoded type as a term rather than a native type"
  key_maxLengthDef = defineAnnotationKey "maxLength" Nothing
  key_minLengthDef = defineAnnotationKey "minLength" Nothing
  key_preserveFieldNameDef = defineAnnotationKey "preserveFieldName" Nothing
  key_typeDef = defineAnnotationKey "type" Nothing
  key_freshTypeVariableCountDef = defineAnnotationKey "freshTypeVariableCount" $
    Just "A counter for generating fresh type variable names"
  
  maxInt32Def :: TBinding Int
  maxInt32Def = define "maxInt32" $
    doc "The maximum value of a 32-bit integer" $
    int32 maxBound
  
  placeholderNameDef :: TBinding Name
  placeholderNameDef = define "placeholderName" $
    doc "A placeholder name for row types as they are being constructed" $
    wrap _Name $ string "Placeholder"
  
  maxTraceDepthDef :: TBinding Int
  maxTraceDepthDef = define "maxTraceDepth" $
    doc ("A maximum depth for nested flows."
      <> " Currently, this is set very high because deep flows are common in type inference over the Hydra kernel.") $
    int32 4000
  
  warningAutoGeneratedFileDef :: TBinding String
  warningAutoGeneratedFileDef = define "warningAutoGeneratedFile" $
    string "Note: this is an automatically generated file. Do not edit."
  