From 5f14cd051df5163f992a0b4a7469df315fb27421 Mon Sep 17 00:00:00 2001 From: TheMatten Date: Fri, 23 Oct 2020 09:56:15 +0200 Subject: [PATCH 1/2] Remove optimization phases, update package.yaml-s --- package.yaml | 4 +- polysemy-plugin/package.yaml | 2 + polysemy-plugin/polysemy-plugin.cabal | 8 ++- polysemy-plugin/src/Polysemy/Plugin.hs | 29 --------- polysemy-plugin/src/Polysemy/Plugin/Phases.hs | 63 ------------------- polysemy.cabal | 9 ++- 6 files changed, 16 insertions(+), 99 deletions(-) delete mode 100644 polysemy-plugin/src/Polysemy/Plugin/Phases.hs diff --git a/package.yaml b/package.yaml index 1b58e184..7fe5575c 100644 --- a/package.yaml +++ b/package.yaml @@ -23,7 +23,7 @@ dependencies: - syb >= 0.7 && < 0.8 - stm >= 2 && < 3 - template-haskell >= 2.12.0.0 && < 3 -- th-abstraction >= 0.3.1.0 && < 0.4 +- th-abstraction >= 0.3.1.0 && < 0.5 - transformers >= 0.5.2.0 && < 0.6 - first-class-families >= 0.5.0.0 && < 0.9 - unagi-chan >= 0.4.0.0 && < 0.5 @@ -119,6 +119,8 @@ tests: - inspection-testing >= 0.4.2 && < 0.5 - hspec >= 2.6.0 && < 3 - doctest >= 0.16.0.1 && < 0.17 + generated-other-modules: + - Build_doctests benchmarks: polysemy-bench: diff --git a/polysemy-plugin/package.yaml b/polysemy-plugin/package.yaml index b5cd91a2..9aa608d4 100644 --- a/polysemy-plugin/package.yaml +++ b/polysemy-plugin/package.yaml @@ -63,6 +63,8 @@ tests: - should-not-typecheck >= 2.1.0 && < 3 - inspection-testing >= 0.4.2 && < 0.5 - doctest >= 0.16.0.1 && < 0.17 + generated-other-modules: + - Build_doctests default-extensions: - DataKinds diff --git a/polysemy-plugin/polysemy-plugin.cabal b/polysemy-plugin/polysemy-plugin.cabal index 001d92d6..b4322a26 100644 --- a/polysemy-plugin/polysemy-plugin.cabal +++ b/polysemy-plugin/polysemy-plugin.cabal @@ -1,10 +1,10 @@ -cabal-version: 1.24 +cabal-version: 2.0 -- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack -- --- hash: 0f4635d86ee9b6424b575257afd4fc1a42b0ddbbf2270bdcb1a71b8e54f0226d +-- hash: c7e130178c5199be49659c43bf9e2d9dc5792c21c41b81b7ba50279ebea963e0 name: polysemy-plugin version: 0.2.5.1 @@ -45,7 +45,6 @@ library Polysemy.Plugin.Fundep.Stuff Polysemy.Plugin.Fundep.Unification Polysemy.Plugin.Fundep.Utils - Polysemy.Plugin.Phases other-modules: Paths_polysemy_plugin hs-source-dirs: @@ -74,6 +73,9 @@ test-suite polysemy-plugin-test TypeErrors VDQSpec Paths_polysemy_plugin + Build_doctests + autogen-modules: + Build_doctests hs-source-dirs: test default-extensions: DataKinds DeriveFunctor FlexibleContexts GADTs LambdaCase PolyKinds RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UnicodeSyntax diff --git a/polysemy-plugin/src/Polysemy/Plugin.hs b/polysemy-plugin/src/Polysemy/Plugin.hs index 96c5119f..9f0dcad4 100644 --- a/polysemy-plugin/src/Polysemy/Plugin.hs +++ b/polysemy-plugin/src/Polysemy/Plugin.hs @@ -62,43 +62,14 @@ module Polysemy.Plugin ) where import Polysemy.Plugin.Fundep -#if __GLASGOW_HASKELL__ >= 810 -import Polysemy.Plugin.Phases -import Data.Bool (bool) -#endif import GhcPlugins - ------------------------------------------------------------------------------ plugin :: Plugin plugin = defaultPlugin { tcPlugin = const $ Just fundepPlugin - , installCoreToDos = const installTodos #if __GLASGOW_HASKELL__ >= 806 , pluginRecompile = purePlugin #endif } - ------------------------------------------------------------------------------- -#if __GLASGOW_HASKELL__ >= 810 -polysemyInternal :: ModuleName -polysemyInternal = mkModuleName "Polysemy.Internal" -#endif - ------------------------------------------------------------------------------- -installTodos :: [CoreToDo] -> CoreM [CoreToDo] -installTodos todos = do - dflags <- getDynFlags - - case optLevel dflags of - 0 -> pure todos - _ -> do -#if __GLASGOW_HASKELL__ >= 810 - mods <- moduleSetElts <$> getVisibleOrphanMods - pure $ todos ++ bool [] - (extraPhases dflags) - (any ((== polysemyInternal) . moduleName) mods) -#else - pure todos -#endif diff --git a/polysemy-plugin/src/Polysemy/Plugin/Phases.hs b/polysemy-plugin/src/Polysemy/Plugin/Phases.hs deleted file mode 100644 index 6f4be85e..00000000 --- a/polysemy-plugin/src/Polysemy/Plugin/Phases.hs +++ /dev/null @@ -1,63 +0,0 @@ -{-# LANGUAGE CPP #-} - -module Polysemy.Plugin.Phases - ( extraPhases - ) where - -import BasicTypes -import CoreMonad -import DynFlags - -extraPhases :: DynFlags -> [CoreToDo] -extraPhases dflags = - [ CoreDoSpecialising - , simpl_phase 0 ["post-late-spec"] max_iter - , simpl_gently - , CoreDoStaticArgs - , CoreDoSpecialising - -- TODO(sandy): probably don't need this one - , simpl_phase 0 ["post-late-spec"] max_iter - , simpl_phases - , simpl_gently - ] - - where - option = flip gopt dflags - max_iter = maxSimplIterations dflags - rules_on = option Opt_DoLambdaEtaExpansion - phases = simplPhases dflags - - base_mode = SimplMode - { sm_phase = error "base_mode" - , sm_names = [] -#if __GLASGOW_HASKELL__ >= 804 - , sm_dflags = dflags -#endif - , sm_rules = option Opt_EnableRewriteRules - , sm_eta_expand = rules_on - , sm_inline = True - , sm_case_case = True - } - - simpl_phase phase names iter = CoreDoPasses - [ runWhen (phase `elem` strictnessBefore dflags) CoreDoStrictness - , CoreDoSimplify iter $ - base_mode { sm_phase = Phase phase - , sm_names = names - } - , runMaybe (ruleCheck dflags) $ CoreDoRuleCheck $ Phase phase - ] - - simpl_gently = CoreDoSimplify max_iter $ base_mode - { sm_phase = InitialPhase - , sm_names = ["Gentle"] - , sm_rules = rules_on - , sm_inline = True - , sm_case_case = False - } - - simpl_phases = CoreDoPasses - [ simpl_phase phase ["main"] max_iter - | phase <- [phases, phases-1 .. 1] - ] - diff --git a/polysemy.cabal b/polysemy.cabal index e07c0ffd..1e2f8275 100644 --- a/polysemy.cabal +++ b/polysemy.cabal @@ -1,10 +1,10 @@ -cabal-version: 1.24 +cabal-version: 2.0 --- This file has been generated from package.yaml by hpack version 0.34.2. +-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack -- --- hash: 6f6080a4e65486639af03142e56fdf232ed5c7747e77c24b378b0bb8033a079d +-- hash: fa7aaa2419a7bc1c1779979b304e87f5840d10146f3f23d1b4d93ac1ddbc028f name: polysemy version: 1.3.0.0 @@ -145,6 +145,9 @@ test-suite polysemy-test ViewSpec WriterSpec Paths_polysemy + Build_doctests + autogen-modules: + Build_doctests hs-source-dirs: test default-extensions: DataKinds DeriveFunctor FlexibleContexts GADTs LambdaCase PolyKinds RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UnicodeSyntax From 146ea88d11438dd0a93513affd9b1b9f7b994935 Mon Sep 17 00:00:00 2001 From: TheMatten Date: Fri, 23 Oct 2020 11:00:23 +0200 Subject: [PATCH 2/2] Add Paths_* to generated-other-modules --- package.yaml | 2 ++ polysemy-plugin/package.yaml | 2 ++ polysemy-plugin/polysemy-plugin.cabal | 4 +++- polysemy.cabal | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.yaml b/package.yaml index 7fe5575c..ba1192c1 100644 --- a/package.yaml +++ b/package.yaml @@ -77,6 +77,8 @@ library: ghc-options: -Wall source-dirs: src other-modules: Polysemy.Internal.PluginLookup + generated-other-modules: + - Paths_polysemy when: - condition: flag(dump-core) diff --git a/polysemy-plugin/package.yaml b/polysemy-plugin/package.yaml index 9aa608d4..7a38966e 100644 --- a/polysemy-plugin/package.yaml +++ b/polysemy-plugin/package.yaml @@ -33,6 +33,8 @@ custom-setup: library: source-dirs: src + generated-other-modules: + - Paths_polysemy_plugin flags: corelint: diff --git a/polysemy-plugin/polysemy-plugin.cabal b/polysemy-plugin/polysemy-plugin.cabal index b4322a26..9b379e6b 100644 --- a/polysemy-plugin/polysemy-plugin.cabal +++ b/polysemy-plugin/polysemy-plugin.cabal @@ -4,7 +4,7 @@ cabal-version: 2.0 -- -- see: https://github.com/sol/hpack -- --- hash: c7e130178c5199be49659c43bf9e2d9dc5792c21c41b81b7ba50279ebea963e0 +-- hash: 44327db7470ebcb50b7141a3a17ffde2130f69401c24dbed443290623f8547dc name: polysemy-plugin version: 0.2.5.1 @@ -47,6 +47,8 @@ library Polysemy.Plugin.Fundep.Utils other-modules: Paths_polysemy_plugin + autogen-modules: + Paths_polysemy_plugin hs-source-dirs: src default-extensions: DataKinds DeriveFunctor FlexibleContexts GADTs LambdaCase PolyKinds RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UnicodeSyntax diff --git a/polysemy.cabal b/polysemy.cabal index 1e2f8275..dcaa666b 100644 --- a/polysemy.cabal +++ b/polysemy.cabal @@ -4,7 +4,7 @@ cabal-version: 2.0 -- -- see: https://github.com/sol/hpack -- --- hash: fa7aaa2419a7bc1c1779979b304e87f5840d10146f3f23d1b4d93ac1ddbc028f +-- hash: 1ca26628a20b44d39a0c528cd42cb065833e803157c026d19b1ecacc770f59dc name: polysemy version: 1.3.0.0 @@ -87,6 +87,9 @@ library Polysemy.Writer other-modules: Polysemy.Internal.PluginLookup + Paths_polysemy + autogen-modules: + Paths_polysemy hs-source-dirs: src default-extensions: DataKinds DeriveFunctor FlexibleContexts GADTs LambdaCase PolyKinds RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UnicodeSyntax