diff --git a/app/Commands/Dev/Core/Compile/Base.hs b/app/Commands/Dev/Core/Compile/Base.hs index f3f12fe10..76e3194d2 100644 --- a/app/Commands/Dev/Core/Compile/Base.hs +++ b/app/Commands/Dev/Core/Compile/Base.hs @@ -159,7 +159,7 @@ runTreePipeline pa@PipelineArg {..} = do r <- runReader entryPoint . runError @JuvixError - . coreToTree Core.Identity + . coreToTree Core.IdentityTrans $ _pipelineArgModule tab' <- getRight r let code = Tree.ppPrint tab' tab' diff --git a/app/Commands/Dev/Core/Strip.hs b/app/Commands/Dev/Core/Strip.hs index fcb04c680..e2f3a679b 100644 --- a/app/Commands/Dev/Core/Strip.hs +++ b/app/Commands/Dev/Core/Strip.hs @@ -16,7 +16,7 @@ runCommand opts = do run . runReader (project' @Core.CoreOptions gopts) . runError @JuvixError - $ Core.toStripped' Core.Identity (Core.moduleFromInfoTable tab) + $ Core.toStripped' Core.IdentityTrans (Core.moduleFromInfoTable tab) tab' <- getRight $ mapRight (Stripped.fromCore (project gopts ^. Core.optFieldSize) . Core.computeCombinedInfoTable) r unless (project opts ^. coreStripNoPrint) $ do renderStdOut (Core.ppOut opts tab') diff --git a/src/Juvix/Compiler/Core/Data/TransformationId.hs b/src/Juvix/Compiler/Core/Data/TransformationId.hs index a073931ca..8212152b6 100644 --- a/src/Juvix/Compiler/Core/Data/TransformationId.hs +++ b/src/Juvix/Compiler/Core/Data/TransformationId.hs @@ -13,7 +13,7 @@ data TransformationId | NatToPrimInt | IntToPrimInt | ConvertBuiltinTypes - | Identity + | IdentityTrans | UnrollRecursion | ComputeTypeInfo | MatchToCase @@ -92,7 +92,7 @@ instance TransformationId' TransformationId where MatchToCase -> strMatchToCase NaiveMatchToCase -> strNaiveMatchToCase EtaExpandApps -> strEtaExpandApps - Identity -> strIdentity + IdentityTrans -> strIdentity RemoveTypeArgs -> strRemoveTypeArgs MoveApps -> strMoveApps NatToPrimInt -> strNatToPrimInt @@ -144,5 +144,5 @@ instance PipelineId' TransformationId PipelineId where PipelineNormalize -> toNormalizeTransformations PipelineGeb -> toGebTransformations PipelineVampIR -> toVampIRTransformations - PipelineStripped -> toStrippedTransformations Identity + PipelineStripped -> toStrippedTransformations IdentityTrans PipelineExec -> toStrippedTransformations CheckExec diff --git a/src/Juvix/Compiler/Core/Transformation.hs b/src/Juvix/Compiler/Core/Transformation.hs index ba160116b..5eb7ecc98 100644 --- a/src/Juvix/Compiler/Core/Transformation.hs +++ b/src/Juvix/Compiler/Core/Transformation.hs @@ -25,7 +25,7 @@ import Juvix.Compiler.Core.Transformation.ConvertBuiltinTypes import Juvix.Compiler.Core.Transformation.DisambiguateNames import Juvix.Compiler.Core.Transformation.Eta import Juvix.Compiler.Core.Transformation.FoldTypeSynonyms -import Juvix.Compiler.Core.Transformation.Identity +import Juvix.Compiler.Core.Transformation.IdentityTrans import Juvix.Compiler.Core.Transformation.IntToPrimInt import Juvix.Compiler.Core.Transformation.LambdaLetRecLifting import Juvix.Compiler.Core.Transformation.LetHoisting @@ -66,7 +66,7 @@ applyTransformations ts tbl = foldM (flip appTrans) tbl ts appTrans = \case LambdaLetRecLifting -> return . lambdaLetRecLifting LetRecLifting -> return . letRecLifting - Identity -> return . identity + IdentityTrans -> return . identity TopEtaExpand -> return . topEtaExpand RemoveTypeArgs -> return . removeTypeArgs MoveApps -> return . moveApps diff --git a/src/Juvix/Compiler/Core/Transformation/Identity.hs b/src/Juvix/Compiler/Core/Transformation/IdentityTrans.hs similarity index 60% rename from src/Juvix/Compiler/Core/Transformation/Identity.hs rename to src/Juvix/Compiler/Core/Transformation/IdentityTrans.hs index c6189ab52..dc45bbc23 100644 --- a/src/Juvix/Compiler/Core/Transformation/Identity.hs +++ b/src/Juvix/Compiler/Core/Transformation/IdentityTrans.hs @@ -1,5 +1,5 @@ -module Juvix.Compiler.Core.Transformation.Identity - ( module Juvix.Compiler.Core.Transformation.Identity, +module Juvix.Compiler.Core.Transformation.IdentityTrans + ( module Juvix.Compiler.Core.Transformation.IdentityTrans, module Juvix.Compiler.Core.Transformation.Base, ) where diff --git a/src/Juvix/Compiler/Pipeline.hs b/src/Juvix/Compiler/Pipeline.hs index 20dd6fcbf..d75ffc7a3 100644 --- a/src/Juvix/Compiler/Pipeline.hs +++ b/src/Juvix/Compiler/Pipeline.hs @@ -156,7 +156,7 @@ upToTree :: (Members '[HighlightBuilder, Reader Parser.ParserResult, Reader EntryPoint, Reader Store.ModuleTable, Files, NameIdGen, Error JuvixError] r) => Sem r Tree.InfoTable upToTree = - upToStoredCore >>= \Core.CoreResult {..} -> storedCoreToTree Core.Identity _coreResultModule + upToStoredCore >>= \Core.CoreResult {..} -> storedCoreToTree Core.IdentityTrans _coreResultModule upToAsm :: (Members '[HighlightBuilder, Reader Parser.ParserResult, Reader EntryPoint, Reader Store.ModuleTable, Files, NameIdGen, Error JuvixError] r) => diff --git a/src/Juvix/Compiler/Reg/Data/TransformationId.hs b/src/Juvix/Compiler/Reg/Data/TransformationId.hs index 89b690b77..f93bde484 100644 --- a/src/Juvix/Compiler/Reg/Data/TransformationId.hs +++ b/src/Juvix/Compiler/Reg/Data/TransformationId.hs @@ -5,7 +5,7 @@ import Juvix.Compiler.Reg.Data.TransformationId.Strings import Juvix.Prelude data TransformationId - = Identity + = IdentityTrans | Cleanup | SSA | InitBranchVars @@ -31,7 +31,7 @@ toCasmTransformations = [Cleanup, SSA] instance TransformationId' TransformationId where transformationText :: TransformationId -> Text transformationText = \case - Identity -> strIdentity + IdentityTrans -> strIdentity Cleanup -> strCleanup SSA -> strSSA InitBranchVars -> strInitBranchVars diff --git a/src/Juvix/Compiler/Reg/Transformation.hs b/src/Juvix/Compiler/Reg/Transformation.hs index d46496992..315e634bb 100644 --- a/src/Juvix/Compiler/Reg/Transformation.hs +++ b/src/Juvix/Compiler/Reg/Transformation.hs @@ -8,7 +8,7 @@ where import Juvix.Compiler.Reg.Data.TransformationId import Juvix.Compiler.Reg.Transformation.Base import Juvix.Compiler.Reg.Transformation.Cleanup -import Juvix.Compiler.Reg.Transformation.Identity +import Juvix.Compiler.Reg.Transformation.IdentityTrans import Juvix.Compiler.Reg.Transformation.InitBranchVars import Juvix.Compiler.Reg.Transformation.SSA @@ -17,7 +17,7 @@ applyTransformations ts tbl = foldM (flip appTrans) tbl ts where appTrans :: TransformationId -> InfoTable -> Sem r InfoTable appTrans = \case - Identity -> return . identity + IdentityTrans -> return . identity Cleanup -> return . cleanup SSA -> return . computeSSA InitBranchVars -> return . initBranchVars diff --git a/src/Juvix/Compiler/Reg/Transformation/Identity.hs b/src/Juvix/Compiler/Reg/Transformation/IdentityTrans.hs similarity index 72% rename from src/Juvix/Compiler/Reg/Transformation/Identity.hs rename to src/Juvix/Compiler/Reg/Transformation/IdentityTrans.hs index 34378afba..11acc37c5 100644 --- a/src/Juvix/Compiler/Reg/Transformation/Identity.hs +++ b/src/Juvix/Compiler/Reg/Transformation/IdentityTrans.hs @@ -1,4 +1,4 @@ -module Juvix.Compiler.Reg.Transformation.Identity where +module Juvix.Compiler.Reg.Transformation.IdentityTrans where import Juvix.Compiler.Reg.Extra.Recursors import Juvix.Compiler.Reg.Transformation.Base diff --git a/src/Juvix/Compiler/Tree/Data/TransformationId.hs b/src/Juvix/Compiler/Tree/Data/TransformationId.hs index 93f8c22be..6b0b5d25a 100644 --- a/src/Juvix/Compiler/Tree/Data/TransformationId.hs +++ b/src/Juvix/Compiler/Tree/Data/TransformationId.hs @@ -5,7 +5,7 @@ import Juvix.Compiler.Tree.Data.TransformationId.Strings import Juvix.Prelude data TransformationId - = Identity + = IdentityTrans | IdentityU | IdentityD | Apply @@ -35,7 +35,7 @@ toCairoAsmTransformations = [Validate, Apply, FilterUnreachable] instance TransformationId' TransformationId where transformationText :: TransformationId -> Text transformationText = \case - Identity -> strIdentity + IdentityTrans -> strIdentity IdentityU -> strIdentityU IdentityD -> strIdentityD Apply -> strApply diff --git a/src/Juvix/Compiler/Tree/Transformation.hs b/src/Juvix/Compiler/Tree/Transformation.hs index a1876de89..e78c7ce17 100644 --- a/src/Juvix/Compiler/Tree/Transformation.hs +++ b/src/Juvix/Compiler/Tree/Transformation.hs @@ -12,7 +12,7 @@ import Juvix.Compiler.Tree.Transformation.Apply import Juvix.Compiler.Tree.Transformation.Base import Juvix.Compiler.Tree.Transformation.CheckNoAnoma import Juvix.Compiler.Tree.Transformation.FilterUnreachable -import Juvix.Compiler.Tree.Transformation.Identity +import Juvix.Compiler.Tree.Transformation.IdentityTrans import Juvix.Compiler.Tree.Transformation.TempHeight import Juvix.Compiler.Tree.Transformation.Validate @@ -21,7 +21,7 @@ applyTransformations ts tbl = foldM (flip appTrans) tbl ts where appTrans :: TransformationId -> InfoTable -> Sem r InfoTable appTrans = \case - Identity -> return . identity + IdentityTrans -> return . identity IdentityU -> return . identityU IdentityD -> return . identityD Apply -> return . computeApply diff --git a/src/Juvix/Compiler/Tree/Transformation/Identity.hs b/src/Juvix/Compiler/Tree/Transformation/IdentityTrans.hs similarity index 79% rename from src/Juvix/Compiler/Tree/Transformation/Identity.hs rename to src/Juvix/Compiler/Tree/Transformation/IdentityTrans.hs index 1b1847418..d3163502c 100644 --- a/src/Juvix/Compiler/Tree/Transformation/Identity.hs +++ b/src/Juvix/Compiler/Tree/Transformation/IdentityTrans.hs @@ -1,5 +1,5 @@ -module Juvix.Compiler.Tree.Transformation.Identity - ( module Juvix.Compiler.Tree.Transformation.Identity, +module Juvix.Compiler.Tree.Transformation.IdentityTrans + ( module Juvix.Compiler.Tree.Transformation.IdentityTrans, module Juvix.Compiler.Tree.Transformation.Base, ) where diff --git a/src/Juvix/Prelude/Base/Foundation.hs b/src/Juvix/Prelude/Base/Foundation.hs index 373804f1c..7e8217f39 100644 --- a/src/Juvix/Prelude/Base/Foundation.hs +++ b/src/Juvix/Prelude/Base/Foundation.hs @@ -39,6 +39,7 @@ module Juvix.Prelude.Base.Foundation module Data.Text.IO, module Data.Text.IO.Utf8, module Data.Traversable, + module Data.Functor.Identity, module Data.Tuple.Extra, module Data.Typeable, module Data.Void, @@ -95,6 +96,7 @@ import Data.Eq import Data.Foldable hiding (foldr1, minimum, minimumBy) import Data.Function import Data.Functor +import Data.Functor.Identity import Data.Graph (Graph, SCC (..), Vertex, stronglyConnComp) import Data.HashMap.Lazy qualified as LazyHashMap import Data.HashMap.Strict (HashMap) diff --git a/test/Core/Asm/Base.hs b/test/Core/Asm/Base.hs index 74d65ff2e..15429393a 100644 --- a/test/Core/Asm/Base.hs +++ b/test/Core/Asm/Base.hs @@ -53,8 +53,17 @@ coreAsmAssertion mainFile expectedFile step = do assertEqDiffText ("Check: EVAL output = " <> toFilePath expectedFile) "" expected Right (tabIni, Just node) -> do step "Translate" - case run $ runReader defaultCoreOptions $ runError $ toStored' >=> toStripped' Identity $ moduleFromInfoTable $ setupMainFunction defaultModuleId tabIni node of + case run + . runReader defaultCoreOptions + . runError + . (toStored' >=> toStripped' IdentityTrans) + . moduleFromInfoTable + $ setupMainFunction defaultModuleId tabIni node of Left err -> assertFailure (prettyString (fromJuvixError @GenericError err)) Right m -> do - let tab = Asm.fromTree $ Tree.fromCore $ Stripped.fromCore (maximum allowedFieldSizes) $ computeCombinedInfoTable m + let tab = + Asm.fromTree + . Tree.fromCore + . Stripped.fromCore (maximum allowedFieldSizes) + $ computeCombinedInfoTable m Asm.asmRunAssertion' tab expectedFile step diff --git a/test/Core/Transformation.hs b/test/Core/Transformation.hs index a339b3a59..86fa30756 100644 --- a/test/Core/Transformation.hs +++ b/test/Core/Transformation.hs @@ -1,7 +1,7 @@ module Core.Transformation where import Base -import Core.Transformation.Identity qualified as Identity +import Core.Transformation.IdentityTrans qualified as IdentityTrans import Core.Transformation.Lifting qualified as Lifting import Core.Transformation.Pipeline qualified as Pipeline import Core.Transformation.TopEtaExpand qualified as TopEtaExpand @@ -11,7 +11,7 @@ allTests :: TestTree allTests = testGroup "JuvixCore transformations" - [ Identity.allTests, + [ IdentityTrans.allTests, TopEtaExpand.allTests, Lifting.allTests, Pipeline.allTests, diff --git a/test/Core/Transformation/Identity.hs b/test/Core/Transformation/IdentityTrans.hs similarity index 83% rename from test/Core/Transformation/Identity.hs rename to test/Core/Transformation/IdentityTrans.hs index bbe9a69a4..17d7d555a 100644 --- a/test/Core/Transformation/Identity.hs +++ b/test/Core/Transformation/IdentityTrans.hs @@ -1,4 +1,4 @@ -module Core.Transformation.Identity (allTests) where +module Core.Transformation.IdentityTrans (allTests) where import Base import Core.Eval.Positive qualified as Eval @@ -9,7 +9,7 @@ allTests :: TestTree allTests = testGroup "Identity" (map liftTest Eval.tests) pipe :: [TransformationId] -pipe = [Identity] +pipe = [IdentityTrans] liftTest :: Eval.PosTest -> TestTree liftTest _testEval = diff --git a/test/Core/Transformation/Pipeline.hs b/test/Core/Transformation/Pipeline.hs index b92fa5bb0..0df36d228 100644 --- a/test/Core/Transformation/Pipeline.hs +++ b/test/Core/Transformation/Pipeline.hs @@ -9,7 +9,7 @@ allTests :: TestTree allTests = testGroup "Transformation pipeline (to Stripped)" (map liftTest Eval.compilableTests) pipe :: [TransformationId] -pipe = toStoredTransformations ++ toStrippedTransformations Identity +pipe = toStoredTransformations ++ toStrippedTransformations IdentityTrans liftTest :: Eval.PosTest -> TestTree liftTest _testEval = diff --git a/test/Reg/Transformation.hs b/test/Reg/Transformation.hs index 7f0b9033d..7590f0808 100644 --- a/test/Reg/Transformation.hs +++ b/test/Reg/Transformation.hs @@ -1,7 +1,7 @@ module Reg.Transformation where import Base -import Reg.Transformation.Identity qualified as Identity +import Reg.Transformation.IdentityTrans qualified as IdentityTrans import Reg.Transformation.InitBranchVars qualified as InitBranchVars import Reg.Transformation.SSA qualified as SSA @@ -9,7 +9,7 @@ allTests :: TestTree allTests = testGroup "JuvixReg transformations" - [ Identity.allTests, + [ IdentityTrans.allTests, SSA.allTests, InitBranchVars.allTests ] diff --git a/test/Reg/Transformation/Identity.hs b/test/Reg/Transformation/IdentityTrans.hs similarity index 86% rename from test/Reg/Transformation/Identity.hs rename to test/Reg/Transformation/IdentityTrans.hs index 7817686fe..758ac3761 100644 --- a/test/Reg/Transformation/Identity.hs +++ b/test/Reg/Transformation/IdentityTrans.hs @@ -1,4 +1,4 @@ -module Reg.Transformation.Identity where +module Reg.Transformation.IdentityTrans where import Base import Juvix.Compiler.Reg.Transformation @@ -9,7 +9,7 @@ allTests :: TestTree allTests = testGroup "Identity" (map liftTest Parse.tests) pipe :: [TransformationId] -pipe = [Identity] +pipe = [IdentityTrans] liftTest :: Parse.PosTest -> TestTree liftTest _testRun = diff --git a/test/Tree/Transformation.hs b/test/Tree/Transformation.hs index 03147269e..2a360724e 100644 --- a/test/Tree/Transformation.hs +++ b/test/Tree/Transformation.hs @@ -3,14 +3,14 @@ module Tree.Transformation where import Base import Tree.Transformation.Apply qualified as Apply import Tree.Transformation.CheckNoAnoma qualified as CheckNoAnoma -import Tree.Transformation.Identity qualified as Identity +import Tree.Transformation.IdentityTrans qualified as IdentityTrans import Tree.Transformation.Reachability qualified as Reachability allTests :: TestTree allTests = testGroup "JuvixTree transformations" - [ Identity.allTests, + [ IdentityTrans.allTests, Apply.allTests, Reachability.allTests, CheckNoAnoma.allTests diff --git a/test/Tree/Transformation/Identity.hs b/test/Tree/Transformation/IdentityTrans.hs similarity index 80% rename from test/Tree/Transformation/Identity.hs rename to test/Tree/Transformation/IdentityTrans.hs index e17afdb2a..1502a465f 100644 --- a/test/Tree/Transformation/Identity.hs +++ b/test/Tree/Transformation/IdentityTrans.hs @@ -1,4 +1,4 @@ -module Tree.Transformation.Identity (allTests) where +module Tree.Transformation.IdentityTrans (allTests) where import Base import Juvix.Compiler.Tree.Transformation @@ -9,7 +9,7 @@ allTests :: TestTree allTests = testGroup "Identity" (map liftTest Eval.tests) pipe :: [TransformationId] -pipe = [Identity, IdentityU, IdentityD] +pipe = [IdentityTrans, IdentityU, IdentityD] liftTest :: Eval.PosTest -> TestTree liftTest _testEval =