invariant 0.5.4 → 0.5.5
raw patch · 7 files changed
+57/−33 lines, 7 filesdep ~template-haskelldep ~transformersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: template-haskell, transformers
API changes (from Hackage documentation)
- Data.Functor.Invariant: instance forall k (g :: * -> *) (a :: k). Data.Functor.Invariant.Invariant g => Data.Functor.Invariant.Invariant (Data.Bifunctor.Joker.Joker g a)
- Data.Functor.Invariant: instance forall k1 (p :: * -> * -> *) (q :: k1 -> * -> *) (a :: k1). Data.Functor.Invariant.Invariant2 p => Data.Functor.Invariant.Invariant (Data.Profunctor.Composition.Procompose p q a)
- Data.Functor.Invariant: instance forall k1 (p :: * -> * -> *) (q :: k1 -> * -> *) (a :: k1). Data.Functor.Invariant.Invariant2 p => Data.Functor.Invariant.Invariant (Data.Profunctor.Composition.Rift p q a)
- Data.Functor.Invariant: newtype WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1) :: forall k k1. () => k -> k1 -> Type -> k -> k1 -> Type
+ Data.Functor.Invariant: instance forall k1 (g :: * -> *) (a :: k1). Data.Functor.Invariant.Invariant g => Data.Functor.Invariant.Invariant (Data.Bifunctor.Joker.Joker g a)
+ Data.Functor.Invariant: instance forall k2 (p :: * -> * -> *) (q :: k2 -> * -> *) (a :: k2). Data.Functor.Invariant.Invariant2 p => Data.Functor.Invariant.Invariant (Data.Profunctor.Composition.Procompose p q a)
+ Data.Functor.Invariant: instance forall k2 (p :: * -> * -> *) (q :: k2 -> * -> *) (a :: k2). Data.Functor.Invariant.Invariant2 p => Data.Functor.Invariant.Invariant (Data.Profunctor.Composition.Rift p q a)
+ Data.Functor.Invariant: newtype WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1)
- Data.Functor.Invariant: WrapBifunctor :: p a b -> WrappedBifunctor
+ Data.Functor.Invariant: WrapBifunctor :: p a b -> WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1)
- Data.Functor.Invariant: [unwrapBifunctor] :: WrappedBifunctor -> p a b
+ Data.Functor.Invariant: [unwrapBifunctor] :: WrappedBifunctor (p :: k -> k1 -> Type) (a :: k) (b :: k1) -> p a b
Files
- CHANGELOG.md +4/−0
- README.md +1/−1
- invariant.cabal +8/−6
- src/Data/Functor/Invariant.hs +26/−12
- src/Data/Functor/Invariant/TH.hs +8/−4
- src/Data/Functor/Invariant/TH/Internal.hs +2/−2
- test/THSpec.hs +8/−8
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.5.5 [2021.11.01]+* Allow building with GHC 9.2.+* Allow building with `transformers-0.6.*`.+ # 0.5.4 [2020.10.01] * Fix a bug in which `deriveInvariant2` would fail on certain data types with three or parameters if the first two parameters had phantom roles.
README.md view
@@ -3,7 +3,7 @@ [](http://packdeps.haskellers.com/reverse/invariant) [][Haskell.org] [][tl;dr Legal: BSD3]-[](https://travis-ci.org/nfrisby/invariant-functors)+[](https://github.com/nfrisby/invariant-functors/actions?query=workflow%3AHaskell-CI) [Hackage: invariant]: http://hackage.haskell.org/package/invariant
invariant.cabal view
@@ -1,5 +1,5 @@ name: invariant-version: 0.5.4+version: 0.5.5 synopsis: Haskell98 invariant functors description: Haskell98 invariant functors (also known as exponential functors). .@@ -26,8 +26,10 @@ , GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.5- , GHC == 8.8.3- , GHC == 8.10.1+ , GHC == 8.8.4+ , GHC == 8.10.7+ , GHC == 9.0.1+ , GHC == 9.2.1 extra-source-files: CHANGELOG.md, README.md source-repository head@@ -52,9 +54,9 @@ , StateVar >= 1.1 && < 2 , stm >= 2.2 && < 3 , tagged >= 0.7.3 && < 1- , template-haskell >= 2.4 && < 2.18+ , template-haskell >= 2.4 && < 2.19 , th-abstraction >= 0.4 && < 0.5- , transformers >= 0.2 && < 0.6+ , transformers >= 0.2 && < 0.7 , transformers-compat >= 0.3 && < 1 , unordered-containers >= 0.2.4 && < 0.3 ghc-options: -Wall@@ -73,7 +75,7 @@ , hspec >= 1.8 , invariant , QuickCheck >= 2.11 && < 3- , template-haskell >= 2.4 && < 2.18+ , template-haskell >= 2.4 && < 2.19 build-tool-depends: hspec-discover:hspec-discover ghc-options: -Wall if impl(ghc >= 8.6)
src/Data/Functor/Invariant.hs view
@@ -1,5 +1,8 @@ {-# LANGUAGE CPP #-}++#if !(MIN_VERSION_base(4,16,0)) || !(MIN_VERSION_transformers(0,6,0)) {-# OPTIONS_GHC -fno-warn-deprecations #-}+#endif #define GHC_GENERICS_OK __GLASGOW_HASKELL__ >= 702 @@ -75,7 +78,10 @@ #endif import Data.Monoid (Dual(..), Endo(..)) import Data.Proxy (Proxy(..))-import qualified Data.Semigroup as Semigroup (First(..), Last(..), Option(..))+import qualified Data.Semigroup as Semigroup (First(..), Last(..))+#if !(MIN_VERSION_base(4,16,0))+import qualified Data.Semigroup as Semigroup (Option(..))+#endif import Data.Semigroup (Min(..), Max(..), Arg(..)) import qualified Data.Traversable as T (Traversable(..)) #if GHC_GENERICS_OK@@ -143,10 +149,8 @@ import Control.Applicative.Backwards (Backwards(..)) import Control.Applicative.Lift (Lift(..)) import Control.Monad.Trans.Cont (ContT)-import Control.Monad.Trans.Error (ErrorT(..)) import Control.Monad.Trans.Except (ExceptT(..), runExceptT) import Control.Monad.Trans.Identity (IdentityT, mapIdentityT)-import Control.Monad.Trans.List (ListT, mapListT) import Control.Monad.Trans.Maybe (MaybeT, mapMaybeT) import qualified Control.Monad.Trans.RWS.Lazy as Lazy (RWST(..)) import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST(..))@@ -155,6 +159,10 @@ import qualified Control.Monad.Trans.State.Strict as Strict (StateT(..)) import qualified Control.Monad.Trans.Writer.Lazy as Lazy (WriterT, mapWriterT) import qualified Control.Monad.Trans.Writer.Strict as Strict (WriterT, mapWriterT)+#if !(MIN_VERSION_transformers(0,6,0))+import Control.Monad.Trans.Error (ErrorT(..))+import Control.Monad.Trans.List (ListT, mapListT)+#endif import Data.Functor.Constant (Constant(..)) import Data.Functor.Reverse (Reverse(..)) @@ -303,11 +311,13 @@ instance Invariant Semigroup.Last where invmap = invmapFunctor -- | from "Data.Semigroup"-instance Invariant Semigroup.Option where+instance Invariant (Arg a) where invmap = invmapFunctor+#if !(MIN_VERSION_base(4,16,0)) -- | from "Data.Semigroup"-instance Invariant (Arg a) where+instance Invariant Semigroup.Option where invmap = invmapFunctor+#endif -- | from "System.Console.GetOpt" instance Invariant ArgDescr where@@ -472,9 +482,6 @@ -- | from the @transformers@ package instance Invariant (ContT r m) where invmap = invmapFunctor--- -- | from the @transformers@ package-instance Invariant m => Invariant (ErrorT e m) where- invmap f g = ErrorT . invmap (invmap f g) (invmap g f) . runErrorT -- | from the @transformers@ package instance Invariant m => Invariant (ExceptT e m) where invmap f g = ExceptT . invmap (invmap f g) (invmap g f) . runExceptT@@ -482,9 +489,6 @@ instance Invariant m => Invariant (IdentityT m) where invmap f g = mapIdentityT (invmap f g) -- | from the @transformers@ package-instance Invariant m => Invariant (ListT m) where- invmap f g = mapListT $ invmap (invmap f g) (invmap g f)--- | from the @transformers@ package instance Invariant m => Invariant (MaybeT m) where invmap f g = mapMaybeT $ invmap (invmap f g) (invmap g f) -- | from the @transformers@ package@@ -530,6 +534,14 @@ -- | from the @transformers@ package instance Invariant f => Invariant (Reverse f) where invmap f g (Reverse a) = Reverse (invmap f g a)+#if !(MIN_VERSION_transformers(0,6,0))+-- | from the @transformers@ package+instance Invariant m => Invariant (ErrorT e m) where+ invmap f g = ErrorT . invmap (invmap f g) (invmap g f) . runErrorT+-- | from the @transformers@ package+instance Invariant m => Invariant (ListT m) where+ invmap f g = mapListT $ invmap (invmap f g) (invmap g f)+#endif -- | from the @unordered-containers@ package instance Invariant (HashMap k) where@@ -563,9 +575,11 @@ many = WrapFunctor . many . unwrapFunctor instance Monad m => Monad (WrappedFunctor m) where- return = WrapFunctor . return WrapFunctor x >>= f = WrapFunctor (x >>= unwrapFunctor . f)+#if !(MIN_VERSION_base(4,11,0))+ return = WrapFunctor . return WrapFunctor a >> WrapFunctor b = WrapFunctor (a >> b)+#endif instance MonadPlus m => MonadPlus (WrappedFunctor m) where mzero = WrapFunctor mzero
src/Data/Functor/Invariant/TH.hs view
@@ -36,7 +36,7 @@ import Control.Monad (unless, when) import Data.Functor.Invariant.TH.Internal-import Data.List+import qualified Data.List as List import qualified Data.Map as Map ((!), fromList, keys, lookup, member, size) import Data.Maybe @@ -325,7 +325,7 @@ let mapFuns = zip covMaps contraMaps lastTyVars = map varTToName $ drop (length instTys - numNbs) instTys tvMap = Map.fromList $ zip lastTyVars mapFuns- argNames = concat (transpose [covMaps, contraMaps]) ++ [value]+ argNames = concat (List.transpose [covMaps, contraMaps]) ++ [value] lamE (map varP argNames) . appsE $ [ varE $ invmapConstName iClass@@ -507,7 +507,7 @@ -- instance C (Fam [Char]) remainingTysOrigSubst :: [Type] remainingTysOrigSubst =- map (substNamesWithKindStar (union droppedKindVarNames kvNames'))+ map (substNamesWithKindStar (List.union droppedKindVarNames kvNames')) $ take remainingLength varTysOrig isDataFamily :: Bool@@ -866,7 +866,11 @@ -> Q Match mkSimpleConMatch fold conName insides = do varsNeeded <- newNameList "_arg" $ length insides- let pat = ConP conName (map VarP varsNeeded)+ let pat = ConP conName+#if MIN_VERSION_template_haskell(2,18,0)+ []+#endif+ (map VarP varsNeeded) rhs <- fold conName (zipWith (\i v -> i $ VarE v) insides varsNeeded) return $ Match pat (NormalB rhs) []
src/Data/Functor/Invariant/TH/Internal.hs view
@@ -13,7 +13,7 @@ import Data.Foldable (foldr') import Data.Functor.Invariant () -- To import the instances-import Data.List+import qualified Data.List as List import qualified Data.Map as Map (singleton) import Data.Map (Map) import Data.Maybe (fromMaybe, mapMaybe)@@ -324,7 +324,7 @@ -- | Construct a type via curried application. applyTy :: Type -> [Type] -> Type-applyTy = foldl' AppT+applyTy = List.foldl' AppT -- | Fully applies a type constructor to its type variables. applyTyCon :: Name -> [Type] -> Type
test/THSpec.hs view
@@ -226,12 +226,12 @@ -- | Verifies that @invmap id id = id@ (the other 'invmap' law follows -- as a free theorem: -- https://www.fpcomplete.com/user/edwardk/snippets/fmap).-prop_invmapLaws :: (Eq (f a), Invariant f) => f a -> Bool-prop_invmapLaws x = invmap id id x == x+prop_invmapLaws :: (Eq (f a), Show (f a), Invariant f) => f a -> Expectation+prop_invmapLaws x = invmap id id x `shouldBe` x -- | Verifies that @invmap2 id id id id = id@.-prop_invmap2Laws :: (Eq (f a b), Invariant2 f) => f a b -> Bool-prop_invmap2Laws x = invmap2 id id id id x == x+prop_invmap2Laws :: (Eq (f a b), Show (f a b), Invariant2 f) => f a b -> Expectation+prop_invmap2Laws x = invmap2 id id id id x `shouldBe` x ------------------------------------------------------------------------------- @@ -241,10 +241,10 @@ spec :: Spec spec = do describe "Compose Maybe Either Int Int" $ do- prop "satisfies the invmap laws" (prop_invmapLaws :: Compose Maybe Either Int Int -> Bool)- prop "satisfies the invmap2 laws" (prop_invmap2Laws :: Compose Maybe Either Int Int -> Bool)+ prop "satisfies the invmap laws" (prop_invmapLaws :: Compose Maybe Either Int Int -> Expectation)+ prop "satisfies the invmap2 laws" (prop_invmap2Laws :: Compose Maybe Either Int Int -> Expectation) #if MIN_VERSION_template_haskell(2,7,0) describe "ComposeFam Maybe Either Int Int" $ do- prop "satisfies the invmap laws" (prop_invmapLaws :: ComposeFam Maybe Either Int Int -> Bool)- prop "satisfies the invmap2 laws" (prop_invmap2Laws :: ComposeFam Maybe Either Int Int -> Bool)+ prop "satisfies the invmap laws" (prop_invmapLaws :: ComposeFam Maybe Either Int Int -> Expectation)+ prop "satisfies the invmap2 laws" (prop_invmap2Laws :: ComposeFam Maybe Either Int Int -> Expectation) #endif