packages feed

polysemy-plugin 0.2.3.0 → 0.2.4.0

raw patch · 5 files changed

+84/−26 lines, 5 filesbuild-type:Customsetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,7 +1,12 @@ # Changelog for polysemy-plugin +## 0.2.4.0 (2019-10-29) +- The plugin now works on GHC 8.8.1 (thanks to @googleson78 and @sevanspowell)+- Improved error messages for when you forgot to include `polysemy` itself+ ## 0.2.3.0 (2019-09-04)+ - The plugin will now choose between given effects based on the ability to unify them.     This makes it possible for disambiguation to kick in even when using multiple     instances of the same effect with different type variables,
Setup.hs view
@@ -1,2 +1,3 @@-import Distribution.Simple-main = defaultMain+import Distribution.Extra.Doctest (defaultMainWithDoctests)++main = defaultMainWithDoctests "polysemy-plugin-test"
polysemy-plugin.cabal view
@@ -1,13 +1,13 @@-cabal-version: 1.12+cabal-version: 1.24  -- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 01634ce3c7ac101e60c1a02f8ccad7ec499c02a04b66e5d9dd5993f314318097+-- hash: 82e62a325b42351fc99bb87c3d491920a5a047c179e686cd398c82a9870f5e46  name:           polysemy-plugin-version:        0.2.3.0+version:        0.2.4.0 synopsis:       Disambiguate obvious uses of effects. description:    Please see the README on GitHub at <https://github.com/isovector/polysemy/tree/master/polysemy-plugin#readme> category:       Polysemy@@ -18,7 +18,7 @@ copyright:      2019 Sandy Maguire license:        BSD3 license-file:   LICENSE-build-type:     Simple+build-type:     Custom extra-source-files:     README.md     ChangeLog.md@@ -27,6 +27,17 @@   type: git   location: https://github.com/isovector/polysemy +custom-setup+  setup-depends:+      Cabal+    , base >=4.9 && <5+    , cabal-doctest >=1.0.6 && <1.1++flag corelint+  description: Perform the corelint tests+  manual: True+  default: False+ library   exposed-modules:       Polysemy.Plugin@@ -82,4 +93,6 @@     , should-not-typecheck >=2.1.0 && <3     , syb >=0.7 && <0.8     , transformers >=0.5.2.0 && <0.6+  if flag(corelint)+    ghc-options: -dcore-lint -dsuppress-all   default-language: Haskell2010
src/Polysemy/Plugin/Fundep/Stuff.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ module Polysemy.Plugin.Fundep.Stuff   ( PolysemyStuff (..)   , LookupState (..)@@ -9,7 +11,10 @@ import GHC (Name, Class, TyCon, mkModuleName) import GHC.TcPluginM.Extra (lookupModule, lookupName) import OccName (mkTcOcc)-import TcPluginM (TcPluginM, tcLookupClass, tcLookupTyCon)+import TcPluginM (TcPluginM, tcLookupClass, tcLookupTyCon, unsafeTcPluginTcM)+import GhcPlugins (getDynFlags)+import Packages (lookupModuleWithSuggestions, LookupResult (..))+import Outputable (pprPanic, empty, text, (<+>), ($$))   @@ -39,12 +44,30 @@ ------------------------------------------------------------------------------ -- | Lookup all of the 'PolysemyStuff'. polysemyStuff :: TcPluginM (PolysemyStuff 'Things)-polysemyStuff =+polysemyStuff = do+  dflags <- unsafeTcPluginTcM getDynFlags++  let error_msg = pprPanic "polysemy-plugin"+          $ text ""+         $$ text "--------------------------------------------------------------------------------"+         $$ text "`polysemy-plugin` is loaded, but"+        <+> text "`polysemy` isn't available as a package."+         $$ text "Probable fix: add `polysemy` to your cabal `build-depends`"+         $$ text "--------------------------------------------------------------------------------"+         $$ text ""+  case lookupModuleWithSuggestions dflags (mkModuleName "Polysemy") Nothing of+    LookupHidden _ _ -> error_msg+    LookupNotFound _ -> error_msg+#if __GLASGOW_HASKELL__ >= 806+    LookupUnusable _ -> error_msg+#endif+    _                -> pure ()+   let PolysemyStuff a b c d = polysemyStuffLocations-   in PolysemyStuff <$> doLookup a-                    <*> doLookup b-                    <*> doLookup c-                    <*> doLookup d+  PolysemyStuff <$> doLookup a+                <*> doLookup b+                <*> doLookup c+                <*> doLookup d   ------------------------------------------------------------------------------
test/DoctestSpec.hs view
@@ -5,23 +5,12 @@ import Test.Hspec import Test.DocTest +import Build_doctests (flags, pkgs, module_sources)+ spec :: Spec-spec = parallel $ describe "Error messages" $ it "should pass the doctest" $ doctest+spec = parallel $ describe "Error messages" $ it "should pass the doctest" $ doctest $   [ "--fast"   , "-fobject-code"-  , "-XDataKinds"-  , "-XDeriveFunctor"-  , "-XFlexibleContexts"-  , "-XGADTs"-  , "-XLambdaCase"-  , "-XPolyKinds"-  , "-XRankNTypes"-  , "-XScopedTypeVariables"-  , "-XStandaloneDeriving"-  , "-XTypeApplications"-  , "-XTypeFamilies"-  , "-XTypeOperators"-  , "-XUnicodeSyntax"  #if __GLASGOW_HASKELL__ < 806   , "-XMonadFailDesugaring"@@ -30,3 +19,30 @@    , "test/TypeErrors.hs"   ]+  <> pkgs+  <> removeFlagSearchPathSrc flags++-- | Designed to remove flags that add the "polysemy-plugin/src" directory. For+-- example, it will remove the following flag:+-- "-i/Users/bob/code/polysemy/polysemy-plugin/src".+--+-- This was done because the presence of this flag causes the following error:+--   test/TypeErrors.hs:9: failure in expression `:set -fplugin=Polysemy.Plugin'+--   expected:   +--    but got: attempting to use module ‘main:Polysemy.Plugin’+--    (.../polysemy/polysemy-plugin/src/Polysemy/Plugin.hs) which is not loaded.+--+-- Without this flag, the tests pass as expected. My understanding of GHC isn't+-- great, so feel free to remove this function if you know of some way of making+-- this flag a non-issue.+removeFlagSearchPathSrc :: [String] -> [String]+removeFlagSearchPathSrc = filter (not . isSrcSearchPath)+  where+    isSrcSearchPath flag = isSearchPathFlag flag && isSrcDir flag++    isSearchPathFlag ('-':'i':_) = True+    isSearchPathFlag _           = False++    isSrcDir ('s':'r':c':[]) = True+    isSrcDir (x:xs)          = isSrcDir xs+    isSrcDir []              = False