From a6ac12cdca0c3a6463f355e25d8f92a1c147c525 Mon Sep 17 00:00:00 2001 From: Jonathan Cubides Date: Mon, 25 Jul 2022 17:14:13 +0200 Subject: [PATCH] Refactor of typechecking and other checking processes (#1410) * Refactor in progress * Fixing imports and missing references * Remove unnecessary import --- app/Main.hs | 8 +++---- .../ArityChecker.hs => Analysis/Arity.hs} | 12 +++++----- .../ArityChecker => Analysis/Arity}/Arity.hs | 2 +- .../ArityChecker => Analysis/Arity}/Error.hs | 8 +++---- .../Arity}/Error/Types.hs | 2 +- .../Arity}/LocalVars.hs | 4 ++-- src/Juvix/Analysis/Positivity.hs | 6 +++++ src/Juvix/Analysis/Positivity/Checker.hs | 2 +- src/Juvix/Analysis/Scoping.hs | 12 ++++++++++ .../Scoping}/InfoTableBuilder.hs | 4 ++-- .../Scoped => Analysis/Scoping}/Scope.hs | 4 ++-- .../Scoped => Analysis/Scoping}/Scoper.hs | 22 +++++++++---------- .../Scoping}/ScoperResult.hs | 4 ++-- src/Juvix/Analysis/Termination.hs | 12 ++++++++++ .../{ => Analysis}/Termination/Checker.hs | 16 +++++++------- src/Juvix/Analysis/Termination/Error.hs | 19 ++++++++++++++++ .../Termination/Error/Pretty.hs | 10 ++++----- .../Termination/Error/Pretty/Ann.hs | 2 +- .../Termination/Error/Pretty/Ansi.hs | 6 ++--- .../{ => Analysis}/Termination/Error/Types.hs | 4 ++-- .../Termination/FunctionCall.hs | 6 ++--- .../{ => Analysis}/Termination/LexOrder.hs | 6 ++--- src/Juvix/Analysis/Termination/Types.hs | 12 ++++++++++ .../Termination/Types/FunctionCall.hs | 4 ++-- .../{ => Analysis}/Termination/Types/Graph.hs | 8 +++---- .../Termination/Types/SizeInfo.hs | 2 +- .../Termination/Types/SizeRelation.hs | 2 +- src/Juvix/Analysis/TypeChecking.hs | 10 +++++++++ .../TypeChecking/Checker.hs} | 6 ++--- .../TypeChecking}/FunctionsTable.hs | 2 +- .../TypeChecking}/Inference.hs | 8 +++---- src/Juvix/Builtins/Error.hs | 2 +- src/Juvix/Parsing/Base.hs | 1 + .../Concrete/Parser => Parsing}/Error.hs | 2 +- .../Concrete/Parser => Parsing}/InfoTable.hs | 4 ++-- .../Parser => Parsing}/InfoTableBuilder.hs | 8 +++---- .../{Syntax/Concrete => Parsing}/Lexer.hs | 4 ++-- .../Concrete/Parser => Parsing}/ParsedItem.hs | 2 +- .../{Syntax/Concrete => Parsing}/Parser.hs | 20 ++++++++--------- .../Parser => Parsing}/ParserResult.hs | 4 ++-- src/Juvix/Pipeline.hs | 9 ++++---- src/Juvix/Prelude.hs | 2 +- src/Juvix/Syntax/Abstract/AbstractResult.hs | 4 ++-- src/Juvix/Syntax/Concrete/Parser/Base.hs | 1 - .../Syntax/Concrete/Scoped/Error/Types.hs | 4 ++-- src/Juvix/Syntax/Concrete/Scoped/Highlight.hs | 2 +- src/Juvix/Syntax/MicroJuvix/Error.hs | 4 ++-- src/Juvix/Syntax/MonoJuvix/MonoJuvixResult.hs | 2 +- src/Juvix/Termination.hs | 12 ---------- src/Juvix/Termination/Error.hs | 19 ---------------- src/Juvix/Termination/Types.hs | 12 ---------- src/Juvix/Translation/AbstractToMicroJuvix.hs | 4 ++-- src/Juvix/Translation/MicroJuvixToMiniC.hs | 2 +- src/Juvix/Translation/ScopedToAbstract.hs | 2 +- test/Arity/Negative.hs | 2 +- test/Scope/Positive.hs | 4 ++-- test/Termination/Negative.hs | 2 +- 57 files changed, 193 insertions(+), 166 deletions(-) rename src/Juvix/{Syntax/MicroJuvix/ArityChecker.hs => Analysis/Arity.hs} (97%) rename src/Juvix/{Syntax/MicroJuvix/ArityChecker => Analysis/Arity}/Arity.hs (94%) rename src/Juvix/{Syntax/MicroJuvix/ArityChecker => Analysis/Arity}/Error.hs (79%) rename src/Juvix/{Syntax/MicroJuvix/ArityChecker => Analysis/Arity}/Error/Types.hs (99%) rename src/Juvix/{Syntax/MicroJuvix/ArityChecker => Analysis/Arity}/LocalVars.hs (83%) create mode 100644 src/Juvix/Analysis/Positivity.hs create mode 100644 src/Juvix/Analysis/Scoping.hs rename src/Juvix/{Syntax/Concrete/Scoped/Scoper => Analysis/Scoping}/InfoTableBuilder.hs (97%) rename src/Juvix/{Syntax/Concrete/Scoped => Analysis/Scoping}/Scope.hs (96%) rename src/Juvix/{Syntax/Concrete/Scoped => Analysis/Scoping}/Scoper.hs (98%) rename src/Juvix/{Syntax/Concrete/Scoped/Scoper => Analysis/Scoping}/ScoperResult.hs (76%) create mode 100644 src/Juvix/Analysis/Termination.hs rename src/Juvix/{ => Analysis}/Termination/Checker.hs (91%) create mode 100644 src/Juvix/Analysis/Termination/Error.hs rename src/Juvix/{ => Analysis}/Termination/Error/Pretty.hs (71%) rename src/Juvix/{ => Analysis}/Termination/Error/Pretty/Ann.hs (60%) rename src/Juvix/{ => Analysis}/Termination/Error/Pretty/Ansi.hs (68%) rename src/Juvix/{ => Analysis}/Termination/Error/Types.hs (86%) rename src/Juvix/{ => Analysis}/Termination/FunctionCall.hs (94%) rename src/Juvix/{ => Analysis}/Termination/LexOrder.hs (97%) create mode 100644 src/Juvix/Analysis/Termination/Types.hs rename src/Juvix/{ => Analysis}/Termination/Types/FunctionCall.hs (94%) rename src/Juvix/{ => Analysis}/Termination/Types/Graph.hs (91%) rename src/Juvix/{ => Analysis}/Termination/Types/SizeInfo.hs (94%) rename src/Juvix/{ => Analysis}/Termination/Types/SizeRelation.hs (94%) create mode 100644 src/Juvix/Analysis/TypeChecking.hs rename src/Juvix/{Syntax/MicroJuvix/TypeChecker.hs => Analysis/TypeChecking/Checker.hs} (99%) rename src/Juvix/{Syntax/MicroJuvix/TypeChecker => Analysis/TypeChecking}/FunctionsTable.hs (85%) rename src/Juvix/{Syntax/MicroJuvix/TypeChecker => Analysis/TypeChecking}/Inference.hs (98%) create mode 100644 src/Juvix/Parsing/Base.hs rename src/Juvix/{Syntax/Concrete/Parser => Parsing}/Error.hs (95%) rename src/Juvix/{Syntax/Concrete/Parser => Parsing}/InfoTable.hs (65%) rename src/Juvix/{Syntax/Concrete/Parser => Parsing}/InfoTableBuilder.hs (90%) rename src/Juvix/{Syntax/Concrete => Parsing}/Lexer.hs (99%) rename src/Juvix/{Syntax/Concrete/Parser => Parsing}/ParsedItem.hs (89%) rename src/Juvix/{Syntax/Concrete => Parsing}/Parser.hs (97%) rename src/Juvix/{Syntax/Concrete/Parser => Parsing}/ParserResult.hs (75%) delete mode 100644 src/Juvix/Syntax/Concrete/Parser/Base.hs delete mode 100644 src/Juvix/Termination.hs delete mode 100644 src/Juvix/Termination/Error.hs delete mode 100644 src/Juvix/Termination/Types.hs diff --git a/app/Main.hs b/app/Main.hs index bf2592451d..e161999fb4 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -6,24 +6,24 @@ import Commands.Internal.Termination as Termination import Control.Exception qualified as IO import Control.Monad.Extra import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Scoping.Scoper qualified as Scoper +import Juvix.Analysis.Termination qualified as Termination +import Juvix.Analysis.TypeChecking qualified as MicroTyped +import Juvix.Parsing.Parser qualified as Parser import Juvix.Pipeline import Juvix.Prelude hiding (Doc) import Juvix.Prelude.Pretty hiding (Doc) import Juvix.Syntax.Abstract.InfoTable qualified as Abstract import Juvix.Syntax.Abstract.Language qualified as Abstract import Juvix.Syntax.Abstract.Pretty qualified as Abstract -import Juvix.Syntax.Concrete.Parser qualified as Parser import Juvix.Syntax.Concrete.Scoped.Highlight qualified as Highlight import Juvix.Syntax.Concrete.Scoped.InfoTable qualified as Scoper import Juvix.Syntax.Concrete.Scoped.Pretty qualified as Scoper import Juvix.Syntax.Concrete.Scoped.Pretty.Html -import Juvix.Syntax.Concrete.Scoped.Scoper qualified as Scoper import Juvix.Syntax.MicroJuvix.MicroJuvixArityResult qualified as MicroArity import Juvix.Syntax.MicroJuvix.Pretty qualified as Micro -import Juvix.Syntax.MicroJuvix.TypeChecker qualified as MicroTyped import Juvix.Syntax.MiniHaskell.Pretty qualified as MiniHaskell import Juvix.Syntax.MonoJuvix.Pretty qualified as Mono -import Juvix.Termination qualified as Termination import Juvix.Translation.AbstractToMicroJuvix qualified as Micro import Juvix.Translation.MicroJuvixToMiniC qualified as MiniC import Juvix.Translation.MicroJuvixToMonoJuvix qualified as Mono diff --git a/src/Juvix/Syntax/MicroJuvix/ArityChecker.hs b/src/Juvix/Analysis/Arity.hs similarity index 97% rename from src/Juvix/Syntax/MicroJuvix/ArityChecker.hs rename to src/Juvix/Analysis/Arity.hs index e3fb8bdc0a..fb8a369075 100644 --- a/src/Juvix/Syntax/MicroJuvix/ArityChecker.hs +++ b/src/Juvix/Analysis/Arity.hs @@ -1,15 +1,15 @@ -module Juvix.Syntax.MicroJuvix.ArityChecker - ( module Juvix.Syntax.MicroJuvix.ArityChecker, +module Juvix.Analysis.Arity + ( module Juvix.Analysis.Arity, module Juvix.Syntax.MicroJuvix.MicroJuvixArityResult, - module Juvix.Syntax.MicroJuvix.ArityChecker.Error, + module Juvix.Analysis.Arity.Error, ) where +import Juvix.Analysis.Arity.Arity +import Juvix.Analysis.Arity.Error +import Juvix.Analysis.Arity.LocalVars import Juvix.Internal.NameIdGen import Juvix.Prelude hiding (fromEither) -import Juvix.Syntax.MicroJuvix.ArityChecker.Arity -import Juvix.Syntax.MicroJuvix.ArityChecker.Error -import Juvix.Syntax.MicroJuvix.ArityChecker.LocalVars import Juvix.Syntax.MicroJuvix.InfoTable import Juvix.Syntax.MicroJuvix.Language.Extra import Juvix.Syntax.MicroJuvix.MicroJuvixArityResult diff --git a/src/Juvix/Syntax/MicroJuvix/ArityChecker/Arity.hs b/src/Juvix/Analysis/Arity/Arity.hs similarity index 94% rename from src/Juvix/Syntax/MicroJuvix/ArityChecker/Arity.hs rename to src/Juvix/Analysis/Arity/Arity.hs index 0d2c99470b..c6d8af3b05 100644 --- a/src/Juvix/Syntax/MicroJuvix/ArityChecker/Arity.hs +++ b/src/Juvix/Analysis/Arity/Arity.hs @@ -1,4 +1,4 @@ -module Juvix.Syntax.MicroJuvix.ArityChecker.Arity where +module Juvix.Analysis.Arity.Arity where import Juvix.Prelude diff --git a/src/Juvix/Syntax/MicroJuvix/ArityChecker/Error.hs b/src/Juvix/Analysis/Arity/Error.hs similarity index 79% rename from src/Juvix/Syntax/MicroJuvix/ArityChecker/Error.hs rename to src/Juvix/Analysis/Arity/Error.hs index 9e188aeddf..089c3e0fec 100644 --- a/src/Juvix/Syntax/MicroJuvix/ArityChecker/Error.hs +++ b/src/Juvix/Analysis/Arity/Error.hs @@ -1,11 +1,11 @@ -module Juvix.Syntax.MicroJuvix.ArityChecker.Error - ( module Juvix.Syntax.MicroJuvix.ArityChecker.Error, - module Juvix.Syntax.MicroJuvix.ArityChecker.Error.Types, +module Juvix.Analysis.Arity.Error + ( module Juvix.Analysis.Arity.Error, + module Juvix.Analysis.Arity.Error.Types, ) where +import Juvix.Analysis.Arity.Error.Types import Juvix.Prelude -import Juvix.Syntax.MicroJuvix.ArityChecker.Error.Types data ArityCheckerError = ErrWrongConstructorAppLength WrongConstructorAppLength diff --git a/src/Juvix/Syntax/MicroJuvix/ArityChecker/Error/Types.hs b/src/Juvix/Analysis/Arity/Error/Types.hs similarity index 99% rename from src/Juvix/Syntax/MicroJuvix/ArityChecker/Error/Types.hs rename to src/Juvix/Analysis/Arity/Error/Types.hs index 2553553867..b6c2106fd5 100644 --- a/src/Juvix/Syntax/MicroJuvix/ArityChecker/Error/Types.hs +++ b/src/Juvix/Analysis/Arity/Error/Types.hs @@ -1,4 +1,4 @@ -module Juvix.Syntax.MicroJuvix.ArityChecker.Error.Types where +module Juvix.Analysis.Arity.Error.Types where -- import Juvix.Syntax.MicroJuvix.Error.Pretty import Juvix.Prelude diff --git a/src/Juvix/Syntax/MicroJuvix/ArityChecker/LocalVars.hs b/src/Juvix/Analysis/Arity/LocalVars.hs similarity index 83% rename from src/Juvix/Syntax/MicroJuvix/ArityChecker/LocalVars.hs rename to src/Juvix/Analysis/Arity/LocalVars.hs index eeb584d62d..41263d0290 100644 --- a/src/Juvix/Syntax/MicroJuvix/ArityChecker/LocalVars.hs +++ b/src/Juvix/Analysis/Arity/LocalVars.hs @@ -1,8 +1,8 @@ -module Juvix.Syntax.MicroJuvix.ArityChecker.LocalVars where +module Juvix.Analysis.Arity.LocalVars where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Arity.Arity import Juvix.Prelude -import Juvix.Syntax.MicroJuvix.ArityChecker.Arity import Juvix.Syntax.MicroJuvix.Language newtype LocalVars = LocalVars diff --git a/src/Juvix/Analysis/Positivity.hs b/src/Juvix/Analysis/Positivity.hs new file mode 100644 index 0000000000..e440562b79 --- /dev/null +++ b/src/Juvix/Analysis/Positivity.hs @@ -0,0 +1,6 @@ +module Juvix.Analysis.Positivity + ( module Juvix.Analysis.Positivity.Checker, + ) +where + +import Juvix.Analysis.Positivity.Checker diff --git a/src/Juvix/Analysis/Positivity/Checker.hs b/src/Juvix/Analysis/Positivity/Checker.hs index 5a5b708e02..b50d6562e6 100644 --- a/src/Juvix/Analysis/Positivity/Checker.hs +++ b/src/Juvix/Analysis/Positivity/Checker.hs @@ -3,12 +3,12 @@ module Juvix.Analysis.Positivity.Checker where import Data.HashMap.Strict qualified as HashMap import Data.HashSet qualified as HashSet +import Juvix.Analysis.TypeChecking.Inference import Juvix.Pipeline.EntryPoint qualified as E import Juvix.Prelude hiding (fromEither) import Juvix.Syntax.MicroJuvix.Error import Juvix.Syntax.MicroJuvix.InfoTable import Juvix.Syntax.MicroJuvix.Language.Extra -import Juvix.Syntax.MicroJuvix.TypeChecker.Inference type NegativeTypeParameters = HashSet VarName diff --git a/src/Juvix/Analysis/Scoping.hs b/src/Juvix/Analysis/Scoping.hs new file mode 100644 index 0000000000..5c5df55ec6 --- /dev/null +++ b/src/Juvix/Analysis/Scoping.hs @@ -0,0 +1,12 @@ +module Juvix.Analysis.Scoping + ( module Juvix.Analysis.Scoping.Scope, + module Juvix.Analysis.Scoping.Scoper, + module Juvix.Analysis.Scoping.InfoTableBuilder, + module Juvix.Analysis.Scoping.ScoperResult, + ) +where + +import Juvix.Analysis.Scoping.InfoTableBuilder +import Juvix.Analysis.Scoping.Scope +import Juvix.Analysis.Scoping.Scoper +import Juvix.Analysis.Scoping.ScoperResult diff --git a/src/Juvix/Syntax/Concrete/Scoped/Scoper/InfoTableBuilder.hs b/src/Juvix/Analysis/Scoping/InfoTableBuilder.hs similarity index 97% rename from src/Juvix/Syntax/Concrete/Scoped/Scoper/InfoTableBuilder.hs rename to src/Juvix/Analysis/Scoping/InfoTableBuilder.hs index 8d480adf84..99b52bd132 100644 --- a/src/Juvix/Syntax/Concrete/Scoped/Scoper/InfoTableBuilder.hs +++ b/src/Juvix/Analysis/Scoping/InfoTableBuilder.hs @@ -1,10 +1,10 @@ -module Juvix.Syntax.Concrete.Scoped.Scoper.InfoTableBuilder where +module Juvix.Analysis.Scoping.InfoTableBuilder where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Scoping.Scope import Juvix.Prelude import Juvix.Syntax.Concrete.Language import Juvix.Syntax.Concrete.Scoped.Name qualified as S -import Juvix.Syntax.Concrete.Scoped.Scope data InfoTableBuilder m a where RegisterAxiom :: AxiomDef 'Scoped -> InfoTableBuilder m () diff --git a/src/Juvix/Syntax/Concrete/Scoped/Scope.hs b/src/Juvix/Analysis/Scoping/Scope.hs similarity index 96% rename from src/Juvix/Syntax/Concrete/Scoped/Scope.hs rename to src/Juvix/Analysis/Scoping/Scope.hs index d030426519..050a31bff5 100644 --- a/src/Juvix/Syntax/Concrete/Scoped/Scope.hs +++ b/src/Juvix/Analysis/Scoping/Scope.hs @@ -1,5 +1,5 @@ -module Juvix.Syntax.Concrete.Scoped.Scope - ( module Juvix.Syntax.Concrete.Scoped.Scope, +module Juvix.Analysis.Scoping.Scope + ( module Juvix.Analysis.Scoping.Scope, module Juvix.Syntax.Concrete.Scoped.InfoTable, ) where diff --git a/src/Juvix/Syntax/Concrete/Scoped/Scoper.hs b/src/Juvix/Analysis/Scoping/Scoper.hs similarity index 98% rename from src/Juvix/Syntax/Concrete/Scoped/Scoper.hs rename to src/Juvix/Analysis/Scoping/Scoper.hs index 8cb43ab6b5..52192f14b9 100644 --- a/src/Juvix/Syntax/Concrete/Scoped/Scoper.hs +++ b/src/Juvix/Analysis/Scoping/Scoper.hs @@ -1,8 +1,8 @@ -- | Limitations: -- 1. A symbol introduced by a type signature can only be used once per Module. -module Juvix.Syntax.Concrete.Scoped.Scoper - ( module Juvix.Syntax.Concrete.Scoped.Scoper, - module Juvix.Syntax.Concrete.Scoped.Scoper.ScoperResult, +module Juvix.Analysis.Scoping.Scoper + ( module Juvix.Analysis.Scoping.Scoper, + module Juvix.Analysis.Scoping.ScoperResult, module Juvix.Syntax.Concrete.Scoped.Error, ) where @@ -11,22 +11,22 @@ import Control.Monad.Combinators.Expr qualified as P import Data.HashMap.Strict qualified as HashMap import Data.HashSet qualified as HashSet import Data.List.NonEmpty qualified as NonEmpty +import Juvix.Analysis.Scoping.InfoTableBuilder +import Juvix.Analysis.Scoping.Scope +import Juvix.Analysis.Scoping.ScoperResult import Juvix.Internal.NameIdGen +import Juvix.Parsing.InfoTableBuilder (mergeTable) +import Juvix.Parsing.InfoTableBuilder qualified as Parser +import Juvix.Parsing.Parser (runModuleParser) +import Juvix.Parsing.Parser qualified as Parser +import Juvix.Parsing.ParserResult (ParserResult) import Juvix.Pipeline.EntryPoint import Juvix.Prelude import Juvix.Syntax.Concrete.Base qualified as P import Juvix.Syntax.Concrete.Language import Juvix.Syntax.Concrete.Name qualified as N -import Juvix.Syntax.Concrete.Parser (runModuleParser) -import Juvix.Syntax.Concrete.Parser qualified as Parser -import Juvix.Syntax.Concrete.Parser.InfoTableBuilder (mergeTable) -import Juvix.Syntax.Concrete.Parser.InfoTableBuilder qualified as Parser -import Juvix.Syntax.Concrete.Parser.ParserResult (ParserResult) import Juvix.Syntax.Concrete.Scoped.Error import Juvix.Syntax.Concrete.Scoped.Name qualified as S -import Juvix.Syntax.Concrete.Scoped.Scope -import Juvix.Syntax.Concrete.Scoped.Scoper.InfoTableBuilder -import Juvix.Syntax.Concrete.Scoped.Scoper.ScoperResult entryScoper :: Members '[Error ScoperError, Files, NameIdGen] r => diff --git a/src/Juvix/Syntax/Concrete/Scoped/Scoper/ScoperResult.hs b/src/Juvix/Analysis/Scoping/ScoperResult.hs similarity index 76% rename from src/Juvix/Syntax/Concrete/Scoped/Scoper/ScoperResult.hs rename to src/Juvix/Analysis/Scoping/ScoperResult.hs index 470c59bb77..ebf4b1d0dd 100644 --- a/src/Juvix/Syntax/Concrete/Scoped/Scoper/ScoperResult.hs +++ b/src/Juvix/Analysis/Scoping/ScoperResult.hs @@ -1,8 +1,8 @@ -module Juvix.Syntax.Concrete.Scoped.Scoper.ScoperResult where +module Juvix.Analysis.Scoping.ScoperResult where +import Juvix.Parsing.Parser qualified as Parser import Juvix.Prelude import Juvix.Syntax.Concrete.Language -import Juvix.Syntax.Concrete.Parser qualified as Parser import Juvix.Syntax.Concrete.Scoped.InfoTable qualified as Scoped data ScoperResult = ScoperResult diff --git a/src/Juvix/Analysis/Termination.hs b/src/Juvix/Analysis/Termination.hs new file mode 100644 index 0000000000..5bfeaf49c4 --- /dev/null +++ b/src/Juvix/Analysis/Termination.hs @@ -0,0 +1,12 @@ +module Juvix.Analysis.Termination + ( module Juvix.Analysis.Termination.Checker, + module Juvix.Analysis.Termination.Types, + module Juvix.Analysis.Termination.Error, + module Juvix.Analysis.Termination.LexOrder, + ) +where + +import Juvix.Analysis.Termination.Checker +import Juvix.Analysis.Termination.Error +import Juvix.Analysis.Termination.LexOrder +import Juvix.Analysis.Termination.Types diff --git a/src/Juvix/Termination/Checker.hs b/src/Juvix/Analysis/Termination/Checker.hs similarity index 91% rename from src/Juvix/Termination/Checker.hs rename to src/Juvix/Analysis/Termination/Checker.hs index 0d9576a7f3..8017158935 100644 --- a/src/Juvix/Termination/Checker.hs +++ b/src/Juvix/Analysis/Termination/Checker.hs @@ -1,18 +1,18 @@ -module Juvix.Termination.Checker - ( module Juvix.Termination.Checker, - module Juvix.Termination.FunctionCall, - module Juvix.Termination.Error, +module Juvix.Analysis.Termination.Checker + ( module Juvix.Analysis.Termination.Checker, + module Juvix.Analysis.Termination.FunctionCall, + module Juvix.Analysis.Termination.Error, ) where import Data.HashMap.Internal.Strict qualified as HashMap +import Juvix.Analysis.Termination.Error +import Juvix.Analysis.Termination.FunctionCall +import Juvix.Analysis.Termination.LexOrder +import Juvix.Analysis.Termination.Types import Juvix.Prelude import Juvix.Syntax.Abstract.InfoTable as Abstract import Juvix.Syntax.Abstract.Language as Abstract -import Juvix.Termination.Error -import Juvix.Termination.FunctionCall -import Juvix.Termination.LexOrder -import Juvix.Termination.Types checkTermination :: Members '[Error TerminationError] r => diff --git a/src/Juvix/Analysis/Termination/Error.hs b/src/Juvix/Analysis/Termination/Error.hs new file mode 100644 index 0000000000..5f768ca1a0 --- /dev/null +++ b/src/Juvix/Analysis/Termination/Error.hs @@ -0,0 +1,19 @@ +module Juvix.Analysis.Termination.Error + ( module Juvix.Analysis.Termination.Error, + module Juvix.Analysis.Termination.Error.Pretty, + module Juvix.Analysis.Termination.Error.Types, + ) +where + +import Juvix.Analysis.Termination.Error.Pretty +import Juvix.Analysis.Termination.Error.Types +import Juvix.Prelude + +newtype TerminationError + = ErrNoLexOrder NoLexOrder + deriving stock (Show) + +instance ToGenericError TerminationError where + genericError :: TerminationError -> GenericError + genericError = \case + ErrNoLexOrder e -> genericError e diff --git a/src/Juvix/Termination/Error/Pretty.hs b/src/Juvix/Analysis/Termination/Error/Pretty.hs similarity index 71% rename from src/Juvix/Termination/Error/Pretty.hs rename to src/Juvix/Analysis/Termination/Error/Pretty.hs index e3d8e79380..d3cb739af4 100644 --- a/src/Juvix/Termination/Error/Pretty.hs +++ b/src/Juvix/Analysis/Termination/Error/Pretty.hs @@ -1,13 +1,13 @@ -module Juvix.Termination.Error.Pretty - ( module Juvix.Termination.Error.Pretty, - module Juvix.Termination.Error.Pretty.Ann, +module Juvix.Analysis.Termination.Error.Pretty + ( module Juvix.Analysis.Termination.Error.Pretty, + module Juvix.Analysis.Termination.Error.Pretty.Ann, ) where +import Juvix.Analysis.Termination.Error.Pretty.Ann +import Juvix.Analysis.Termination.Error.Pretty.Ansi qualified as Ansi import Juvix.Prelude import Juvix.Prelude.Pretty -import Juvix.Termination.Error.Pretty.Ann -import Juvix.Termination.Error.Pretty.Ansi qualified as Ansi newtype PPOutput = PPOutput (Doc Eann) diff --git a/src/Juvix/Termination/Error/Pretty/Ann.hs b/src/Juvix/Analysis/Termination/Error/Pretty/Ann.hs similarity index 60% rename from src/Juvix/Termination/Error/Pretty/Ann.hs rename to src/Juvix/Analysis/Termination/Error/Pretty/Ann.hs index eb808093ab..7cf44f8357 100644 --- a/src/Juvix/Termination/Error/Pretty/Ann.hs +++ b/src/Juvix/Analysis/Termination/Error/Pretty/Ann.hs @@ -1,4 +1,4 @@ -module Juvix.Termination.Error.Pretty.Ann where +module Juvix.Analysis.Termination.Error.Pretty.Ann where import Juvix.Syntax.Abstract.Pretty.Ann diff --git a/src/Juvix/Termination/Error/Pretty/Ansi.hs b/src/Juvix/Analysis/Termination/Error/Pretty/Ansi.hs similarity index 68% rename from src/Juvix/Termination/Error/Pretty/Ansi.hs rename to src/Juvix/Analysis/Termination/Error/Pretty/Ansi.hs index c161494a71..ff1323159c 100644 --- a/src/Juvix/Termination/Error/Pretty/Ansi.hs +++ b/src/Juvix/Analysis/Termination/Error/Pretty/Ansi.hs @@ -1,11 +1,11 @@ -module Juvix.Termination.Error.Pretty.Ansi - ( module Juvix.Termination.Error.Pretty.Ansi, +module Juvix.Analysis.Termination.Error.Pretty.Ansi + ( module Juvix.Analysis.Termination.Error.Pretty.Ansi, ) where +import Juvix.Analysis.Termination.Error.Pretty.Ann import Juvix.Prelude import Juvix.Syntax.Abstract.Pretty.Ansi qualified as M -import Juvix.Termination.Error.Pretty.Ann import Prettyprinter import Prettyprinter.Render.Terminal diff --git a/src/Juvix/Termination/Error/Types.hs b/src/Juvix/Analysis/Termination/Error/Types.hs similarity index 86% rename from src/Juvix/Termination/Error/Types.hs rename to src/Juvix/Analysis/Termination/Error/Types.hs index 588995ff44..9ae3256fce 100644 --- a/src/Juvix/Termination/Error/Types.hs +++ b/src/Juvix/Analysis/Termination/Error/Types.hs @@ -1,9 +1,9 @@ -module Juvix.Termination.Error.Types where +module Juvix.Analysis.Termination.Error.Types where +import Juvix.Analysis.Termination.Error.Pretty import Juvix.Prelude import Juvix.Prelude.Pretty import Juvix.Syntax.Abstract.Language -import Juvix.Termination.Error.Pretty newtype NoLexOrder = NoLexOrder { _noLexOrderFun :: Name diff --git a/src/Juvix/Termination/FunctionCall.hs b/src/Juvix/Analysis/Termination/FunctionCall.hs similarity index 94% rename from src/Juvix/Termination/FunctionCall.hs rename to src/Juvix/Analysis/Termination/FunctionCall.hs index 0c80c703a8..8a93e6997c 100644 --- a/src/Juvix/Termination/FunctionCall.hs +++ b/src/Juvix/Analysis/Termination/FunctionCall.hs @@ -1,12 +1,12 @@ -module Juvix.Termination.FunctionCall - ( module Juvix.Termination.FunctionCall, +module Juvix.Analysis.Termination.FunctionCall + ( module Juvix.Analysis.Termination.FunctionCall, ) where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Termination.Types import Juvix.Prelude import Juvix.Syntax.Abstract.Language.Extra -import Juvix.Termination.Types viewCall :: forall r. diff --git a/src/Juvix/Termination/LexOrder.hs b/src/Juvix/Analysis/Termination/LexOrder.hs similarity index 97% rename from src/Juvix/Termination/LexOrder.hs rename to src/Juvix/Analysis/Termination/LexOrder.hs index ed6cfc11be..38d54ef145 100644 --- a/src/Juvix/Termination/LexOrder.hs +++ b/src/Juvix/Analysis/Termination/LexOrder.hs @@ -1,13 +1,13 @@ -module Juvix.Termination.LexOrder - ( module Juvix.Termination.LexOrder, +module Juvix.Analysis.Termination.LexOrder + ( module Juvix.Analysis.Termination.LexOrder, ) where import Data.HashMap.Strict qualified as HashMap import Data.HashSet qualified as HashSet +import Juvix.Analysis.Termination.Types import Juvix.Prelude import Juvix.Syntax.Abstract.Language.Extra -import Juvix.Termination.Types fromEdgeList :: [Edge] -> Graph fromEdgeList l = HashMap.fromList [((e ^. edgeFrom, e ^. edgeTo), e) | e <- l] diff --git a/src/Juvix/Analysis/Termination/Types.hs b/src/Juvix/Analysis/Termination/Types.hs new file mode 100644 index 0000000000..534a97c327 --- /dev/null +++ b/src/Juvix/Analysis/Termination/Types.hs @@ -0,0 +1,12 @@ +module Juvix.Analysis.Termination.Types + ( module Juvix.Analysis.Termination.Types.FunctionCall, + module Juvix.Analysis.Termination.Types.Graph, + module Juvix.Analysis.Termination.Types.SizeInfo, + module Juvix.Analysis.Termination.Types.SizeRelation, + ) +where + +import Juvix.Analysis.Termination.Types.FunctionCall +import Juvix.Analysis.Termination.Types.Graph +import Juvix.Analysis.Termination.Types.SizeInfo +import Juvix.Analysis.Termination.Types.SizeRelation diff --git a/src/Juvix/Termination/Types/FunctionCall.hs b/src/Juvix/Analysis/Termination/Types/FunctionCall.hs similarity index 94% rename from src/Juvix/Termination/Types/FunctionCall.hs rename to src/Juvix/Analysis/Termination/Types/FunctionCall.hs index 7d7f65299f..d84d0b0e1d 100644 --- a/src/Juvix/Termination/Types/FunctionCall.hs +++ b/src/Juvix/Analysis/Termination/Types/FunctionCall.hs @@ -1,10 +1,10 @@ -module Juvix.Termination.Types.FunctionCall (module Juvix.Termination.Types.FunctionCall) where +module Juvix.Analysis.Termination.Types.FunctionCall (module Juvix.Analysis.Termination.Types.FunctionCall) where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Termination.Types.SizeRelation import Juvix.Prelude import Juvix.Syntax.Abstract.Language import Juvix.Syntax.Abstract.Pretty.Base -import Juvix.Termination.Types.SizeRelation import Prettyprinter as PP newtype CallMap = CallMap diff --git a/src/Juvix/Termination/Types/Graph.hs b/src/Juvix/Analysis/Termination/Types/Graph.hs similarity index 91% rename from src/Juvix/Termination/Types/Graph.hs rename to src/Juvix/Analysis/Termination/Types/Graph.hs index c209ab3b16..ad580d0289 100644 --- a/src/Juvix/Termination/Types/Graph.hs +++ b/src/Juvix/Analysis/Termination/Types/Graph.hs @@ -1,15 +1,15 @@ -module Juvix.Termination.Types.Graph - ( module Juvix.Termination.Types.Graph, +module Juvix.Analysis.Termination.Types.Graph + ( module Juvix.Analysis.Termination.Types.Graph, ) where import Data.HashSet qualified as HashSet +import Juvix.Analysis.Termination.Types.FunctionCall +import Juvix.Analysis.Termination.Types.SizeRelation import Juvix.Prelude import Juvix.Prelude.Pretty import Juvix.Syntax.Abstract.Language.Extra import Juvix.Syntax.Abstract.Pretty.Base -import Juvix.Termination.Types.FunctionCall -import Juvix.Termination.Types.SizeRelation import Prettyprinter as PP type Graph = HashMap (FunctionName, FunctionName) Edge diff --git a/src/Juvix/Termination/Types/SizeInfo.hs b/src/Juvix/Analysis/Termination/Types/SizeInfo.hs similarity index 94% rename from src/Juvix/Termination/Types/SizeInfo.hs rename to src/Juvix/Analysis/Termination/Types/SizeInfo.hs index 2728b1daa4..1de6c86ad4 100644 --- a/src/Juvix/Termination/Types/SizeInfo.hs +++ b/src/Juvix/Analysis/Termination/Types/SizeInfo.hs @@ -1,4 +1,4 @@ -module Juvix.Termination.Types.SizeInfo where +module Juvix.Analysis.Termination.Types.SizeInfo where import Data.HashMap.Strict qualified as HashMap import Juvix.Prelude diff --git a/src/Juvix/Termination/Types/SizeRelation.hs b/src/Juvix/Analysis/Termination/Types/SizeRelation.hs similarity index 94% rename from src/Juvix/Termination/Types/SizeRelation.hs rename to src/Juvix/Analysis/Termination/Types/SizeRelation.hs index 418c9a4a44..da0a7f64d3 100644 --- a/src/Juvix/Termination/Types/SizeRelation.hs +++ b/src/Juvix/Analysis/Termination/Types/SizeRelation.hs @@ -1,4 +1,4 @@ -module Juvix.Termination.Types.SizeRelation where +module Juvix.Analysis.Termination.Types.SizeRelation where import Data.Semiring import Juvix.Prelude diff --git a/src/Juvix/Analysis/TypeChecking.hs b/src/Juvix/Analysis/TypeChecking.hs new file mode 100644 index 0000000000..b62b86f2ee --- /dev/null +++ b/src/Juvix/Analysis/TypeChecking.hs @@ -0,0 +1,10 @@ +module Juvix.Analysis.TypeChecking + ( module Juvix.Analysis.TypeChecking.Checker, + module Juvix.Analysis.TypeChecking.Inference, + module Juvix.Analysis.TypeChecking.FunctionsTable, + ) +where + +import Juvix.Analysis.TypeChecking.Checker +import Juvix.Analysis.TypeChecking.FunctionsTable +import Juvix.Analysis.TypeChecking.Inference diff --git a/src/Juvix/Syntax/MicroJuvix/TypeChecker.hs b/src/Juvix/Analysis/TypeChecking/Checker.hs similarity index 99% rename from src/Juvix/Syntax/MicroJuvix/TypeChecker.hs rename to src/Juvix/Analysis/TypeChecking/Checker.hs index 64aed41ac4..aa6f54641b 100644 --- a/src/Juvix/Syntax/MicroJuvix/TypeChecker.hs +++ b/src/Juvix/Analysis/TypeChecking/Checker.hs @@ -1,5 +1,5 @@ -module Juvix.Syntax.MicroJuvix.TypeChecker - ( module Juvix.Syntax.MicroJuvix.TypeChecker, +module Juvix.Analysis.TypeChecking.Checker + ( module Juvix.Analysis.TypeChecking.Checker, module Juvix.Syntax.MicroJuvix.MicroJuvixTypedResult, module Juvix.Syntax.MicroJuvix.Error, ) @@ -7,6 +7,7 @@ where import Data.HashMap.Strict qualified as HashMap import Juvix.Analysis.Positivity.Checker +import Juvix.Analysis.TypeChecking.Inference import Juvix.Internal.NameIdGen import Juvix.Pipeline.EntryPoint import Juvix.Prelude hiding (fromEither) @@ -17,7 +18,6 @@ import Juvix.Syntax.MicroJuvix.LocalVars import Juvix.Syntax.MicroJuvix.MicroJuvixArityResult import Juvix.Syntax.MicroJuvix.MicroJuvixTypedResult import Juvix.Syntax.MicroJuvix.Pretty -import Juvix.Syntax.MicroJuvix.TypeChecker.Inference registerConstructor :: Members '[State TypesTable, Reader InfoTable] r => InductiveConstructorDef -> Sem r () registerConstructor ctr = do diff --git a/src/Juvix/Syntax/MicroJuvix/TypeChecker/FunctionsTable.hs b/src/Juvix/Analysis/TypeChecking/FunctionsTable.hs similarity index 85% rename from src/Juvix/Syntax/MicroJuvix/TypeChecker/FunctionsTable.hs rename to src/Juvix/Analysis/TypeChecking/FunctionsTable.hs index deb60b32bd..72e77625de 100644 --- a/src/Juvix/Syntax/MicroJuvix/TypeChecker/FunctionsTable.hs +++ b/src/Juvix/Analysis/TypeChecking/FunctionsTable.hs @@ -1,4 +1,4 @@ -module Juvix.Syntax.MicroJuvix.TypeChecker.FunctionsTable where +module Juvix.Analysis.TypeChecking.FunctionsTable where import Juvix.Prelude import Juvix.Syntax.MicroJuvix.Language diff --git a/src/Juvix/Syntax/MicroJuvix/TypeChecker/Inference.hs b/src/Juvix/Analysis/TypeChecking/Inference.hs similarity index 98% rename from src/Juvix/Syntax/MicroJuvix/TypeChecker/Inference.hs rename to src/Juvix/Analysis/TypeChecking/Inference.hs index 42a3ce5ce2..4c83170180 100644 --- a/src/Juvix/Syntax/MicroJuvix/TypeChecker/Inference.hs +++ b/src/Juvix/Analysis/TypeChecking/Inference.hs @@ -1,15 +1,15 @@ -module Juvix.Syntax.MicroJuvix.TypeChecker.Inference - ( module Juvix.Syntax.MicroJuvix.TypeChecker.Inference, - module Juvix.Syntax.MicroJuvix.TypeChecker.FunctionsTable, +module Juvix.Analysis.TypeChecking.Inference + ( module Juvix.Analysis.TypeChecking.Inference, + module Juvix.Analysis.TypeChecking.FunctionsTable, ) where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.TypeChecking.FunctionsTable import Juvix.Prelude hiding (fromEither) import Juvix.Syntax.MicroJuvix.Error import Juvix.Syntax.MicroJuvix.Language.Extra import Juvix.Syntax.MicroJuvix.MicroJuvixTypedResult -import Juvix.Syntax.MicroJuvix.TypeChecker.FunctionsTable data MetavarState = Fresh diff --git a/src/Juvix/Builtins/Error.hs b/src/Juvix/Builtins/Error.hs index e9e9b58baa..0f78250017 100644 --- a/src/Juvix/Builtins/Error.hs +++ b/src/Juvix/Builtins/Error.hs @@ -1,9 +1,9 @@ module Juvix.Builtins.Error where +import Juvix.Analysis.Termination.Error.Pretty import Juvix.Prelude import Juvix.Prelude.Pretty import Juvix.Syntax.Concrete.Builtins -import Juvix.Termination.Error.Pretty data AlreadyDefined = AlreadyDefined { _alreadyDefinedBuiltin :: BuiltinPrim, diff --git a/src/Juvix/Parsing/Base.hs b/src/Juvix/Parsing/Base.hs new file mode 100644 index 0000000000..cd015821cb --- /dev/null +++ b/src/Juvix/Parsing/Base.hs @@ -0,0 +1 @@ +module Juvix.Parsing.Base where diff --git a/src/Juvix/Syntax/Concrete/Parser/Error.hs b/src/Juvix/Parsing/Error.hs similarity index 95% rename from src/Juvix/Syntax/Concrete/Parser/Error.hs rename to src/Juvix/Parsing/Error.hs index 014f284c15..633d3f6249 100644 --- a/src/Juvix/Syntax/Concrete/Parser/Error.hs +++ b/src/Juvix/Parsing/Error.hs @@ -1,4 +1,4 @@ -module Juvix.Syntax.Concrete.Parser.Error where +module Juvix.Parsing.Error where import Juvix.Prelude import Juvix.Prelude.Pretty diff --git a/src/Juvix/Syntax/Concrete/Parser/InfoTable.hs b/src/Juvix/Parsing/InfoTable.hs similarity index 65% rename from src/Juvix/Syntax/Concrete/Parser/InfoTable.hs rename to src/Juvix/Parsing/InfoTable.hs index 2f4aaa7748..d40c55faa8 100644 --- a/src/Juvix/Syntax/Concrete/Parser/InfoTable.hs +++ b/src/Juvix/Parsing/InfoTable.hs @@ -1,7 +1,7 @@ -module Juvix.Syntax.Concrete.Parser.InfoTable where +module Juvix.Parsing.InfoTable where +import Juvix.Parsing.ParsedItem import Juvix.Prelude -import Juvix.Syntax.Concrete.Parser.ParsedItem newtype InfoTable = InfoTable { _infoParsedItems :: [ParsedItem] diff --git a/src/Juvix/Syntax/Concrete/Parser/InfoTableBuilder.hs b/src/Juvix/Parsing/InfoTableBuilder.hs similarity index 90% rename from src/Juvix/Syntax/Concrete/Parser/InfoTableBuilder.hs rename to src/Juvix/Parsing/InfoTableBuilder.hs index b4fbc3112c..fb5c3f2bad 100644 --- a/src/Juvix/Syntax/Concrete/Parser/InfoTableBuilder.hs +++ b/src/Juvix/Parsing/InfoTableBuilder.hs @@ -1,4 +1,4 @@ -module Juvix.Syntax.Concrete.Parser.InfoTableBuilder +module Juvix.Parsing.InfoTableBuilder ( InfoTableBuilder, registerLiteral, registerKeyword, @@ -6,14 +6,14 @@ module Juvix.Syntax.Concrete.Parser.InfoTableBuilder mergeTable, runInfoTableBuilder, ignoreInfoTableBuilder, - module Juvix.Syntax.Concrete.Parser.InfoTable, + module Juvix.Parsing.InfoTable, ) where +import Juvix.Parsing.InfoTable +import Juvix.Parsing.ParsedItem import Juvix.Prelude import Juvix.Syntax.Concrete.Literal -import Juvix.Syntax.Concrete.Parser.InfoTable -import Juvix.Syntax.Concrete.Parser.ParsedItem import Juvix.Syntax.Loc data InfoTableBuilder m a where diff --git a/src/Juvix/Syntax/Concrete/Lexer.hs b/src/Juvix/Parsing/Lexer.hs similarity index 99% rename from src/Juvix/Syntax/Concrete/Lexer.hs rename to src/Juvix/Parsing/Lexer.hs index 8f81c5d2cd..be2ab47bdc 100644 --- a/src/Juvix/Syntax/Concrete/Lexer.hs +++ b/src/Juvix/Parsing/Lexer.hs @@ -1,12 +1,12 @@ -module Juvix.Syntax.Concrete.Lexer where +module Juvix.Parsing.Lexer where import Data.Text qualified as Text import GHC.Unicode import Juvix.Internal.Strings qualified as Str +import Juvix.Parsing.InfoTableBuilder import Juvix.Prelude import Juvix.Syntax.Concrete.Base hiding (Pos, space) import Juvix.Syntax.Concrete.Base qualified as P -import Juvix.Syntax.Concrete.Parser.InfoTableBuilder import Juvix.Syntax.Loc import Text.Megaparsec.Char.Lexer qualified as L diff --git a/src/Juvix/Syntax/Concrete/Parser/ParsedItem.hs b/src/Juvix/Parsing/ParsedItem.hs similarity index 89% rename from src/Juvix/Syntax/Concrete/Parser/ParsedItem.hs rename to src/Juvix/Parsing/ParsedItem.hs index 898d43c99e..ade8f8b22c 100644 --- a/src/Juvix/Syntax/Concrete/Parser/ParsedItem.hs +++ b/src/Juvix/Parsing/ParsedItem.hs @@ -1,4 +1,4 @@ -module Juvix.Syntax.Concrete.Parser.ParsedItem where +module Juvix.Parsing.ParsedItem where import Juvix.Prelude diff --git a/src/Juvix/Syntax/Concrete/Parser.hs b/src/Juvix/Parsing/Parser.hs similarity index 97% rename from src/Juvix/Syntax/Concrete/Parser.hs rename to src/Juvix/Parsing/Parser.hs index 028868970a..f4a61d0d11 100644 --- a/src/Juvix/Syntax/Concrete/Parser.hs +++ b/src/Juvix/Parsing/Parser.hs @@ -1,23 +1,23 @@ -module Juvix.Syntax.Concrete.Parser - ( module Juvix.Syntax.Concrete.Parser, - module Juvix.Syntax.Concrete.Parser.ParserResult, - module Juvix.Syntax.Concrete.Parser.InfoTable, - module Juvix.Syntax.Concrete.Parser.Error, +module Juvix.Parsing.Parser + ( module Juvix.Parsing.Parser, + module Juvix.Parsing.ParserResult, + module Juvix.Parsing.InfoTable, + module Juvix.Parsing.Error, ) where import Data.List.NonEmpty.Extra qualified as NonEmpty import Data.Singletons +import Juvix.Parsing.Error +import Juvix.Parsing.InfoTable +import Juvix.Parsing.InfoTableBuilder +import Juvix.Parsing.Lexer hiding (symbol) +import Juvix.Parsing.ParserResult import Juvix.Pipeline.EntryPoint import Juvix.Prelude import Juvix.Prelude.Pretty (Pretty, prettyText) import Juvix.Syntax.Concrete.Base qualified as P import Juvix.Syntax.Concrete.Language -import Juvix.Syntax.Concrete.Lexer hiding (symbol) -import Juvix.Syntax.Concrete.Parser.Error -import Juvix.Syntax.Concrete.Parser.InfoTable -import Juvix.Syntax.Concrete.Parser.InfoTableBuilder -import Juvix.Syntax.Concrete.Parser.ParserResult -------------------------------------------------------------------------------- -- Running the parser diff --git a/src/Juvix/Syntax/Concrete/Parser/ParserResult.hs b/src/Juvix/Parsing/ParserResult.hs similarity index 75% rename from src/Juvix/Syntax/Concrete/Parser/ParserResult.hs rename to src/Juvix/Parsing/ParserResult.hs index 252269805c..96bb8eceeb 100644 --- a/src/Juvix/Syntax/Concrete/Parser/ParserResult.hs +++ b/src/Juvix/Parsing/ParserResult.hs @@ -1,9 +1,9 @@ -module Juvix.Syntax.Concrete.Parser.ParserResult where +module Juvix.Parsing.ParserResult where +import Juvix.Parsing.InfoTable import Juvix.Pipeline.EntryPoint import Juvix.Prelude import Juvix.Syntax.Concrete.Language -import Juvix.Syntax.Concrete.Parser.InfoTable data ParserResult = ParserResult { _resultEntry :: EntryPoint, diff --git a/src/Juvix/Pipeline.hs b/src/Juvix/Pipeline.hs index 1e1825a828..82a47306cf 100644 --- a/src/Juvix/Pipeline.hs +++ b/src/Juvix/Pipeline.hs @@ -4,18 +4,17 @@ module Juvix.Pipeline ) where +import Juvix.Analysis.Arity qualified as MicroJuvix +import Juvix.Analysis.Scoping qualified as Scoper +import Juvix.Analysis.TypeChecking qualified as MicroJuvix import Juvix.Builtins import Juvix.Internal.NameIdGen +import Juvix.Parsing.Parser qualified as Parser import Juvix.Pipeline.EntryPoint import Juvix.Pipeline.Setup qualified as Setup import Juvix.Prelude import Juvix.Syntax.Abstract.AbstractResult qualified as Abstract -import Juvix.Syntax.Concrete.Parser qualified as Parser -import Juvix.Syntax.Concrete.Scoped.Scoper qualified as Scoper -import Juvix.Syntax.MicroJuvix.ArityChecker qualified as MicroJuvix import Juvix.Syntax.MicroJuvix.MicroJuvixResult qualified as MicroJuvix -import Juvix.Syntax.MicroJuvix.MicroJuvixTypedResult qualified as MicroJuvix -import Juvix.Syntax.MicroJuvix.TypeChecker qualified as MicroJuvix import Juvix.Translation.AbstractToMicroJuvix qualified as MicroJuvix import Juvix.Translation.MicroJuvixToMiniC qualified as MiniC import Juvix.Translation.MicroJuvixToMonoJuvix qualified as MonoJuvix diff --git a/src/Juvix/Prelude.hs b/src/Juvix/Prelude.hs index 340e2a6e7d..827bba4e56 100644 --- a/src/Juvix/Prelude.hs +++ b/src/Juvix/Prelude.hs @@ -1,10 +1,10 @@ module Juvix.Prelude ( module Juvix.Prelude.Base, - module Juvix.Prelude.Trace, module Juvix.Prelude.Error, module Juvix.Prelude.Files, module Juvix.Prelude.Lens, module Juvix.Prelude.Loc, + module Juvix.Prelude.Trace, ) where diff --git a/src/Juvix/Syntax/Abstract/AbstractResult.hs b/src/Juvix/Syntax/Abstract/AbstractResult.hs index 80a8cbc5f1..15b6953efc 100644 --- a/src/Juvix/Syntax/Abstract/AbstractResult.hs +++ b/src/Juvix/Syntax/Abstract/AbstractResult.hs @@ -4,12 +4,12 @@ module Juvix.Syntax.Abstract.AbstractResult ) where +import Juvix.Analysis.Scoping.ScoperResult +import Juvix.Parsing.ParserResult import Juvix.Pipeline.EntryPoint qualified as E import Juvix.Prelude import Juvix.Syntax.Abstract.InfoTable import Juvix.Syntax.Abstract.Language -import Juvix.Syntax.Concrete.Parser.ParserResult -import Juvix.Syntax.Concrete.Scoped.Scoper.ScoperResult data AbstractResult = AbstractResult { _resultScoper :: ScoperResult, diff --git a/src/Juvix/Syntax/Concrete/Parser/Base.hs b/src/Juvix/Syntax/Concrete/Parser/Base.hs deleted file mode 100644 index d9adece184..0000000000 --- a/src/Juvix/Syntax/Concrete/Parser/Base.hs +++ /dev/null @@ -1 +0,0 @@ -module Juvix.Syntax.Concrete.Parser.Base where diff --git a/src/Juvix/Syntax/Concrete/Scoped/Error/Types.hs b/src/Juvix/Syntax/Concrete/Scoped/Error/Types.hs index 510b542b83..d64b92652b 100644 --- a/src/Juvix/Syntax/Concrete/Scoped/Error/Types.hs +++ b/src/Juvix/Syntax/Concrete/Scoped/Error/Types.hs @@ -8,15 +8,15 @@ where import Data.HashMap.Strict qualified as HashMap import Data.HashSet qualified as HashSet import Data.List.NonEmpty.Extra qualified as NonEmpty +import Juvix.Analysis.Scoping.Scope +import Juvix.Parsing.Error qualified as Parser import Juvix.Prelude import Juvix.Prelude.Pretty import Juvix.Syntax.Concrete.Language import Juvix.Syntax.Concrete.Language qualified as L -import Juvix.Syntax.Concrete.Parser.Error qualified as Parser import Juvix.Syntax.Concrete.Scoped.Error.Ann import Juvix.Syntax.Concrete.Scoped.Error.Pretty import Juvix.Syntax.Concrete.Scoped.Name qualified as S -import Juvix.Syntax.Concrete.Scoped.Scope data MultipleDeclarations = MultipleDeclarations { _multipleDeclEntry :: SymbolEntry, diff --git a/src/Juvix/Syntax/Concrete/Scoped/Highlight.hs b/src/Juvix/Syntax/Concrete/Scoped/Highlight.hs index 47f85d9dc8..5d3cda615c 100644 --- a/src/Juvix/Syntax/Concrete/Scoped/Highlight.hs +++ b/src/Juvix/Syntax/Concrete/Scoped/Highlight.hs @@ -1,8 +1,8 @@ module Juvix.Syntax.Concrete.Scoped.Highlight where import Juvix.Internal.Strings qualified as Str +import Juvix.Parsing.ParsedItem import Juvix.Prelude -import Juvix.Syntax.Concrete.Parser.ParsedItem import Juvix.Syntax.Concrete.Scoped.Name import Prettyprinter import Prettyprinter.Render.Text diff --git a/src/Juvix/Syntax/MicroJuvix/Error.hs b/src/Juvix/Syntax/MicroJuvix/Error.hs index b023c4a15e..84494d7a2f 100644 --- a/src/Juvix/Syntax/MicroJuvix/Error.hs +++ b/src/Juvix/Syntax/MicroJuvix/Error.hs @@ -2,12 +2,12 @@ module Juvix.Syntax.MicroJuvix.Error ( module Juvix.Syntax.MicroJuvix.Error, module Juvix.Syntax.MicroJuvix.Error.Pretty, module Juvix.Syntax.MicroJuvix.Error.Types, - module Juvix.Syntax.MicroJuvix.ArityChecker.Error, + module Juvix.Analysis.Arity.Error, ) where +import Juvix.Analysis.Arity.Error import Juvix.Prelude -import Juvix.Syntax.MicroJuvix.ArityChecker.Error import Juvix.Syntax.MicroJuvix.Error.Pretty import Juvix.Syntax.MicroJuvix.Error.Types diff --git a/src/Juvix/Syntax/MonoJuvix/MonoJuvixResult.hs b/src/Juvix/Syntax/MonoJuvix/MonoJuvixResult.hs index 0a69c9c856..3f44415325 100644 --- a/src/Juvix/Syntax/MonoJuvix/MonoJuvixResult.hs +++ b/src/Juvix/Syntax/MonoJuvix/MonoJuvixResult.hs @@ -5,11 +5,11 @@ module Juvix.Syntax.MonoJuvix.MonoJuvixResult where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Scoping.Scoper qualified as Scoper import Juvix.Prelude import Juvix.Syntax.Abstract.AbstractResult qualified as Abstract import Juvix.Syntax.Concrete.Scoped.InfoTable qualified as Scoper import Juvix.Syntax.Concrete.Scoped.Name qualified as Scoper -import Juvix.Syntax.Concrete.Scoped.Scoper qualified as Scoper import Juvix.Syntax.MicroJuvix.MicroJuvixArityResult qualified as Micro import Juvix.Syntax.MicroJuvix.MicroJuvixResult qualified as Micro import Juvix.Syntax.MicroJuvix.MicroJuvixTypedResult qualified as Micro diff --git a/src/Juvix/Termination.hs b/src/Juvix/Termination.hs deleted file mode 100644 index 9c0ebd39b9..0000000000 --- a/src/Juvix/Termination.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Juvix.Termination - ( module Juvix.Termination.Checker, - module Juvix.Termination.Types, - module Juvix.Termination.Error, - module Juvix.Termination.LexOrder, - ) -where - -import Juvix.Termination.Checker -import Juvix.Termination.Error -import Juvix.Termination.LexOrder -import Juvix.Termination.Types diff --git a/src/Juvix/Termination/Error.hs b/src/Juvix/Termination/Error.hs deleted file mode 100644 index 1ad9bf4879..0000000000 --- a/src/Juvix/Termination/Error.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Juvix.Termination.Error - ( module Juvix.Termination.Error, - module Juvix.Termination.Error.Pretty, - module Juvix.Termination.Error.Types, - ) -where - -import Juvix.Prelude -import Juvix.Termination.Error.Pretty -import Juvix.Termination.Error.Types - -newtype TerminationError - = ErrNoLexOrder NoLexOrder - deriving stock (Show) - -instance ToGenericError TerminationError where - genericError :: TerminationError -> GenericError - genericError = \case - ErrNoLexOrder e -> genericError e diff --git a/src/Juvix/Termination/Types.hs b/src/Juvix/Termination/Types.hs deleted file mode 100644 index 0dde95d921..0000000000 --- a/src/Juvix/Termination/Types.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Juvix.Termination.Types - ( module Juvix.Termination.Types.FunctionCall, - module Juvix.Termination.Types.Graph, - module Juvix.Termination.Types.SizeInfo, - module Juvix.Termination.Types.SizeRelation, - ) -where - -import Juvix.Termination.Types.FunctionCall -import Juvix.Termination.Types.Graph -import Juvix.Termination.Types.SizeInfo -import Juvix.Termination.Types.SizeRelation diff --git a/src/Juvix/Translation/AbstractToMicroJuvix.hs b/src/Juvix/Translation/AbstractToMicroJuvix.hs index 4703c2f3c3..1d7e60c392 100644 --- a/src/Juvix/Translation/AbstractToMicroJuvix.hs +++ b/src/Juvix/Translation/AbstractToMicroJuvix.hs @@ -1,11 +1,12 @@ module Juvix.Translation.AbstractToMicroJuvix ( module Juvix.Translation.AbstractToMicroJuvix, module Juvix.Syntax.MicroJuvix.MicroJuvixResult, - module Juvix.Termination.Checker, + module Juvix.Analysis.Termination.Checker, ) where import Data.HashSet qualified as HashSet +import Juvix.Analysis.Termination.Checker import Juvix.Pipeline.EntryPoint qualified as E import Juvix.Prelude import Juvix.Syntax.Abstract.AbstractResult qualified as Abstract @@ -15,7 +16,6 @@ import Juvix.Syntax.MicroJuvix.Language import Juvix.Syntax.MicroJuvix.Language.Extra import Juvix.Syntax.MicroJuvix.MicroJuvixResult import Juvix.Syntax.Usage -import Juvix.Termination.Checker newtype TranslationState = TranslationState { -- | Top modules are supposed to be included at most once. diff --git a/src/Juvix/Translation/MicroJuvixToMiniC.hs b/src/Juvix/Translation/MicroJuvixToMiniC.hs index 3300c84e91..bf18b84505 100644 --- a/src/Juvix/Translation/MicroJuvixToMiniC.hs +++ b/src/Juvix/Translation/MicroJuvixToMiniC.hs @@ -5,6 +5,7 @@ module Juvix.Translation.MicroJuvixToMiniC where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Scoping.Scoper qualified as Scoper import Juvix.Builtins import Juvix.Internal.Strings qualified as Str import Juvix.Prelude @@ -13,7 +14,6 @@ import Juvix.Syntax.Backends import Juvix.Syntax.Concrete.Language qualified as C import Juvix.Syntax.Concrete.Scoped.InfoTable qualified as Scoper import Juvix.Syntax.Concrete.Scoped.Name qualified as Scoper -import Juvix.Syntax.Concrete.Scoped.Scoper qualified as Scoper import Juvix.Syntax.ForeignBlock import Juvix.Syntax.MicroJuvix.Language.Extra (mkPolyType') import Juvix.Syntax.MicroJuvix.Language.Extra qualified as Micro diff --git a/src/Juvix/Translation/ScopedToAbstract.hs b/src/Juvix/Translation/ScopedToAbstract.hs index 40ff7d58b2..e254108641 100644 --- a/src/Juvix/Translation/ScopedToAbstract.hs +++ b/src/Juvix/Translation/ScopedToAbstract.hs @@ -5,6 +5,7 @@ module Juvix.Translation.ScopedToAbstract where import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Scoping.Scoper qualified as Scoper import Juvix.Builtins import Juvix.Internal.NameIdGen import Juvix.Prelude @@ -16,7 +17,6 @@ import Juvix.Syntax.Concrete.Language qualified as Concrete import Juvix.Syntax.Concrete.Scoped.Error import Juvix.Syntax.Concrete.Scoped.Name qualified as S import Juvix.Syntax.Concrete.Scoped.Name.NameKind -import Juvix.Syntax.Concrete.Scoped.Scoper qualified as Scoper newtype ModulesCache = ModulesCache {_cachedModules :: HashMap S.NameId Abstract.TopModule} diff --git a/test/Arity/Negative.hs b/test/Arity/Negative.hs index 86a79b5852..03bf5e989d 100644 --- a/test/Arity/Negative.hs +++ b/test/Arity/Negative.hs @@ -1,8 +1,8 @@ module Arity.Negative (allTests) where import Base +import Juvix.Analysis.Arity.Error import Juvix.Pipeline -import Juvix.Syntax.MicroJuvix.ArityChecker.Error type FailMsg = String diff --git a/test/Scope/Positive.hs b/test/Scope/Positive.hs index fd2de294e8..75cb295e13 100644 --- a/test/Scope/Positive.hs +++ b/test/Scope/Positive.hs @@ -2,13 +2,13 @@ module Scope.Positive where import Base import Data.HashMap.Strict qualified as HashMap +import Juvix.Analysis.Scoping.Scoper qualified as Scoper import Juvix.Internal.NameIdGen +import Juvix.Parsing.Parser qualified as Parser import Juvix.Pipeline import Juvix.Pipeline.Setup import Juvix.Prelude.Pretty -import Juvix.Syntax.Concrete.Parser qualified as Parser import Juvix.Syntax.Concrete.Scoped.Pretty qualified as M -import Juvix.Syntax.Concrete.Scoped.Scoper qualified as Scoper import Juvix.Syntax.Concrete.Scoped.Utils data PosTest = PosTest diff --git a/test/Termination/Negative.hs b/test/Termination/Negative.hs index b65dc023d5..623d56941c 100644 --- a/test/Termination/Negative.hs +++ b/test/Termination/Negative.hs @@ -1,8 +1,8 @@ module Termination.Negative (module Termination.Negative) where import Base +import Juvix.Analysis.Termination import Juvix.Pipeline -import Juvix.Termination type FailMsg = String