----------------------------------------------------------------------------- -- |The Helium Compiler : Static Analysis -- -- Maintainer : bastiaan@cs.uu.nl -- Stability : experimental -- Portability : unknown -- -- Type inferencing. -- ----------------------------------------------------------------------------- { typeInferencing :: [Option] -> ImportEnvironment -> Module -> (IO (), DictionaryEnvironment, TypeEnvironment, TypeErrors, Warnings) typeInferencing options importEnv module_ = let res = wrap_Module (sem_Module module_) Inh_Module { importEnvironment_Inh_Module = importEnv, options_Inh_Module = options } debugIO = putStrLn (show $ logEntries_Syn_Module res) in (debugIO, dictionaryEnvironment_Syn_Module res, toplevelTypes_Syn_Module res, typeErrors_Syn_Module res, warnings_Syn_Module res) proximaTypeInferencing :: [Option] -> ImportEnvironment -> Module -> (TypeErrors, Warnings, TypeEnvironment, [(Range, TpScheme)]) proximaTypeInferencing options importEnv module_ = let res = wrap_Module (sem_Module module_) Inh_Module { importEnvironment_Inh_Module = importEnv, options_Inh_Module = options } localTypeSchemes = typeSchemesInInfoTree (substitutionFromResult $ solveResult_Syn_Module res) (qualifiersFromResult $ solveResult_Syn_Module res) (infoTree_Syn_Module res) in (typeErrors_Syn_Module res, warnings_Syn_Module res, toplevelTypes_Syn_Module res, localTypeSchemes) } ------------------------------------------------------------------------------- -- Attributes for type inferencing ATTR Module [ importEnvironment : ImportEnvironment options : {[Option]} | | assumptions : Assumptions dictionaryEnvironment : DictionaryEnvironment infoTree : InfoTree logEntries : LogEntries solveResult : {SolveResult ConstraintInfo} toplevelTypes : TypeEnvironment typeErrors : TypeErrors warnings : Warnings ] ------------------------------------------------------------------------------- -- Includes INCLUDE "TypeInferenceRules.ag" INCLUDE "TypeInferenceOverloading.ag" INCLUDE "TypeInferenceCollect.ag" INCLUDE "TypeInferenceInfo.ag" INCLUDE "LocalInfo.ag" INCLUDE "GlobalInfo.ag" INCLUDE "HeliumPartialSyntax.ag" INCLUDE "Scope.ag" INCLUDE "UHA_Syntax.ag" --- Type Inference Directives (may be turned off) INCLUDE "TS_PatternMatching.ag" -- SEM Module | Module lhs . solveResult = @solveResult { debugFromResult = debugFromResult @solveResult -- ++ "Inference Strategies:" -- } -- ++ [ ] @body.matchIO } -- Pattern Match Warnings (may be turned off) INCLUDE "PatternMatchWarnings.ag" SEM Module | Module lhs . warnings = @loc.warnings ++ @body.patternMatchWarnings ------------------------------------------------------------------------------- -- Imports imports { -- types import Top.Types import Helium.StaticAnalysis.Miscellaneous.TypeConversion -- error messages and warnings import Helium.StaticAnalysis.Messages.Messages import Helium.StaticAnalysis.Messages.TypeErrors import Helium.StaticAnalysis.Messages.Warnings import Helium.StaticAnalysis.Miscellaneous.ConstraintInfo import Helium.StaticAnalysis.Miscellaneous.DoublyLinkedTree import Helium.StaticAnalysis.Miscellaneous.UHA_Source -- constraints and constraint trees import Helium.StaticAnalysis.Miscellaneous.TypeConstraints import Top.Ordering.Tree -- constraint solving import Helium.StaticAnalysis.Inferencers.SelectConstraintSolver (selectConstraintSolver) import Top.Solver (SolveResult(..), LogEntries) import Helium.StaticAnalysis.Heuristics.HeuristicsInfo (makeUnifier, skip_UHA_FB_RHS) import Helium.StaticAnalysis.Inferencers.BindingGroupAnalysis -- UHA syntax import Helium.Syntax.UHA_Syntax import Helium.Syntax.UHA_Range -- other import Helium.Utils.Utils (internalError, hole) import Helium.ModuleSystem.ImportEnvironment hiding (setTypeSynonyms) import Helium.ModuleSystem.DictionaryEnvironment import Helium.Main.Args -- standard import qualified Data.Map as M import Data.Maybe }