contravariant 1.5.5 → 1.5.6
raw patch · 7 files changed
+38/−170 lines, 7 filesdep −ghc-primdep −semigroupsdep −taggeddep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: ghc-prim, semigroups, tagged, transformers-compat, void
Dependency ranges changed: base
API changes (from Hackage documentation)
- Data.Functor.Contravariant.Divisible: instance Data.Functor.Contravariant.Divisible.Divisible m => Data.Functor.Contravariant.Divisible.Decidable (Control.Monad.Trans.List.ListT m)
- Data.Functor.Contravariant.Divisible: instance Data.Functor.Contravariant.Divisible.Divisible m => Data.Functor.Contravariant.Divisible.Divisible (Control.Monad.Trans.Error.ErrorT e m)
- Data.Functor.Contravariant.Divisible: instance Data.Functor.Contravariant.Divisible.Divisible m => Data.Functor.Contravariant.Divisible.Divisible (Control.Monad.Trans.List.ListT m)
- Data.Functor.Contravariant.Compose: Compose :: f (g a) -> Compose f g a
+ Data.Functor.Contravariant.Compose: Compose :: f (g a) -> Compose (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Contravariant.Compose: ComposeCF :: f (g a) -> ComposeCF f g a
+ Data.Functor.Contravariant.Compose: ComposeCF :: f (g a) -> ComposeCF (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Contravariant.Compose: ComposeFC :: f (g a) -> ComposeFC f g a
+ Data.Functor.Contravariant.Compose: ComposeFC :: f (g a) -> ComposeFC (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Contravariant.Compose: [getComposeCF] :: ComposeCF f g a -> f (g a)
+ Data.Functor.Contravariant.Compose: [getComposeCF] :: ComposeCF (f :: Type -> Type) (g :: Type -> Type) a -> f (g a)
- Data.Functor.Contravariant.Compose: [getComposeFC] :: ComposeFC f g a -> f (g a)
+ Data.Functor.Contravariant.Compose: [getComposeFC] :: ComposeFC (f :: Type -> Type) (g :: Type -> Type) a -> f (g a)
- Data.Functor.Contravariant.Compose: [getCompose] :: Compose f g a -> f (g a)
+ Data.Functor.Contravariant.Compose: [getCompose] :: Compose (f :: Type -> Type) (g :: Type -> Type) a -> f (g a)
- Data.Functor.Contravariant.Compose: newtype Compose f g a
+ Data.Functor.Contravariant.Compose: newtype Compose (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Contravariant.Compose: newtype ComposeCF f g a
+ Data.Functor.Contravariant.Compose: newtype ComposeCF (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Contravariant.Compose: newtype ComposeFC f g a
+ Data.Functor.Contravariant.Compose: newtype ComposeFC (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Contravariant.Divisible: class Divisible f => Decidable f
+ Data.Functor.Contravariant.Divisible: class Divisible f => Decidable (f :: Type -> Type)
- Data.Functor.Contravariant.Divisible: class Contravariant f => Divisible f
+ Data.Functor.Contravariant.Divisible: class Contravariant f => Divisible (f :: Type -> Type)
- Data.Functor.Contravariant.Generic: class (Generic a, GDeciding q (Rep' a)) => Deciding q a
+ Data.Functor.Contravariant.Generic: class (Generic a, GDeciding q Rep' a) => Deciding (q :: Type -> Constraint) a
- Data.Functor.Contravariant.Generic: class (Generic1 t, GDeciding1 q (Rep1' t)) => Deciding1 q t
+ Data.Functor.Contravariant.Generic: class (Generic1 t, GDeciding1 q Rep1' t) => Deciding1 (q :: Type -> Constraint) (t :: Type -> Type)
Files
- .hlint.yaml +2/−1
- CHANGELOG.markdown +5/−0
- contravariant.cabal +19/−47
- old-src/Data/Functor/Contravariant.hs +7/−70
- src/Data/Functor/Contravariant/Compose.hs +0/−8
- src/Data/Functor/Contravariant/Divisible.hs +5/−32
- src/Data/Functor/Contravariant/Generic.hs +0/−12
.hlint.yaml view
@@ -1,5 +1,6 @@-- arguments: [--cpp-define=HLINT, --cpp-define=GHC_GENERICS, --cpp-ansi]+- arguments: [-XCPP, --cpp-define=HLINT, --cpp-define=GHC_GENERICS, --cpp-ansi] - ignore: {name: Eta reduce} - ignore: {name: Use const} - ignore: {name: Use first}+- ignore: {name: Use void, within: [Data.Functor.Contravariant]}
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+1.5.6 [2026.01.10]+------------------+* Drop support for pre-8.0 versions of GHC.+* Support building with MicroHs.+ 1.5.5 [2021.07.27] ------------------ * Fix the build on old GHCs using `transformers-0.6.*`.
contravariant.cabal view
@@ -1,6 +1,6 @@ name: contravariant category: Control, Data-version: 1.5.5+version: 1.5.6 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -13,19 +13,20 @@ synopsis: Contravariant functors description: Contravariant functors. build-type: Simple-tested-with: GHC == 7.0.4- , GHC == 7.2.2- , GHC == 7.4.2- , GHC == 7.6.3- , GHC == 7.8.4- , GHC == 7.10.3- , GHC == 8.0.2+tested-with: GHC == 8.0.2 , GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.4- , GHC == 8.10.4- , GHC == 9.0.1+ , GHC == 8.10.7+ , GHC == 9.0.2+ , GHC == 9.2.8+ , GHC == 9.4.8+ , GHC == 9.6.7+ , GHC == 9.8.4+ , GHC == 9.10.3+ , GHC == 9.12.2+ , GHC == 9.14.1 extra-source-files: .hlint.yaml CHANGELOG.markdown@@ -33,23 +34,7 @@ source-repository head type: git- location: git://github.com/ekmett/contravariant.git--flag tagged- description:- You can disable the use of the `tagged` package using `-f-tagged`.- .- Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.- default: True- manual: True--flag semigroups- description:- You can disable the use of the `semigroups` package using `-f-semigroups`.- .- Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.- default: True- manual: True+ location: https://github.com/ekmett/contravariant.git flag StateVar description:@@ -62,37 +47,24 @@ library hs-source-dirs: src build-depends:- base < 5,- transformers >= 0.3 && < 0.7-- if !impl(ghc > 7.10)- build-depends: transformers-compat >= 0.5 && < 1-- if !impl(ghc >= 7.9)- build-depends: void >= 0.6.1 && < 1-- if flag(tagged) && !impl(ghc >= 7.7)- build-depends: tagged >= 0.8.6.1 && < 1-- if flag(semigroups) && !impl(ghc >= 7.11)- build-depends: semigroups >= 0.18.5 && < 1+ base >= 4.9 && < 5,+ transformers >= 0.3 && < 0.7 if flag(StateVar) build-depends: StateVar >= 1.2.1 && < 1.3 - if impl(ghc >= 7.2 && < 7.6)- build-depends: ghc-prim- exposed-modules: Data.Functor.Contravariant.Compose Data.Functor.Contravariant.Divisible + if impl(ghc)+ -- MicroHs doesn't support type families yet+ exposed-modules:+ Data.Functor.Contravariant.Generic+ if impl(ghc < 8.5) hs-source-dirs: old-src exposed-modules: Data.Functor.Contravariant-- if impl(ghc >= 7.4)- exposed-modules: Data.Functor.Contravariant.Generic if impl(ghc >= 8.6) ghc-options: -Wno-star-is-type
old-src/Data/Functor/Contravariant.hs view
@@ -1,27 +1,13 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} {-# LANGUAGE TypeOperators #-} -#ifdef __GLASGOW_HASKELL__-#define LANGUAGE_DeriveDataTypeable-{-# LANGUAGE DeriveDataTypeable #-}-#endif--#ifndef MIN_VERSION_tagged-#define MIN_VERSION_tagged(x,y,z) 1-#endif- #ifndef MIN_VERSION_base #define MIN_VERSION_base(x,y,z) 1 #endif -#if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif- #if !(MIN_VERSION_transformers(0,6,0))-{-# OPTIONS_GHC -fno-warn-deprecations #-}+{-# OPTIONS_GHC -Wno-deprecations #-} #endif -----------------------------------------------------------------------------@@ -87,38 +73,21 @@ import Data.Functor.Compose import Data.Functor.Reverse -#if !(MIN_VERSION_transformers(0,6,0))-import Control.Monad.Trans.Error-import Control.Monad.Trans.List-#endif--#if MIN_VERSION_base(4,8,0) import Data.Monoid (Alt(..))-#else-import Data.Monoid (Monoid(..))-#endif--#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711+import Data.Proxy (Proxy(..)) import Data.Semigroup (Semigroup(..))-#endif -#ifdef LANGUAGE_DeriveDataTypeable-import Data.Typeable-#endif+import GHC.Generics -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 707 && defined(VERSION_tagged)-import Data.Proxy+#if !(MIN_VERSION_transformers(0,6,0))+import Control.Monad.Trans.Error+import Control.Monad.Trans.List #endif #ifdef MIN_VERSION_StateVar import Data.StateVar #endif -#if __GLASGOW_HASKELL__ >= 702-#define GHC_GENERICS-import GHC.Generics-#endif- import Prelude hiding ((.),id) -- | The class of contravariant functors.@@ -194,12 +163,9 @@ (>$$<) = flip contramap {-# INLINE (>$$<) #-} -#if MIN_VERSION_base(4,8,0) instance Contravariant f => Contravariant (Alt f) where contramap f = Alt . contramap f . getAlt-#endif -#ifdef GHC_GENERICS instance Contravariant V1 where contramap _ x = x `seq` undefined @@ -225,7 +191,6 @@ instance (Contravariant f, Contravariant g) => Contravariant (f :+: g) where contramap f (L1 xs) = L1 (contramap f xs) contramap f (R1 ys) = R1 (contramap f ys)-#endif instance Contravariant m => Contravariant (ExceptT e m) where contramap f = ExceptT . contramap (fmap f) . runExceptT@@ -300,52 +265,36 @@ {-# INLINE contramap #-} #endif -#if (__GLASGOW_HASKELL__ >= 707) || defined(VERSION_tagged) instance Contravariant Proxy where contramap _ _ = Proxy-#endif newtype Predicate a = Predicate { getPredicate :: a -> Bool }-#ifdef LANGUAGE_DeriveDataTypeable- deriving Typeable-#endif -- | A 'Predicate' is a 'Contravariant' 'Functor', because 'contramap' can -- apply its function argument to the input of the predicate. instance Contravariant Predicate where contramap f g = Predicate $ getPredicate g . f -#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711 instance Semigroup (Predicate a) where Predicate p <> Predicate q = Predicate $ \a -> p a && q a-#endif instance Monoid (Predicate a) where mempty = Predicate $ const True-#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711 mappend = (<>)-#else- mappend (Predicate p) (Predicate q) = Predicate $ \a -> p a && q a-#endif -- | Defines a total ordering on a type as per 'compare'. -- -- This condition is not checked by the types. You must ensure that the supplied -- values are valid total orderings yourself. newtype Comparison a = Comparison { getComparison :: a -> a -> Ordering }-#ifdef LANGUAGE_DeriveDataTypeable- deriving Typeable-#endif -- | A 'Comparison' is a 'Contravariant' 'Functor', because 'contramap' can -- apply its function argument to each input of the comparison function. instance Contravariant Comparison where contramap f g = Comparison $ on (getComparison g) f -#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711 instance Semigroup (Comparison a) where Comparison p <> Comparison q = Comparison $ mappend p q-#endif instance Monoid (Comparison a) where mempty = Comparison (\_ _ -> EQ)@@ -377,9 +326,6 @@ -- -- The types alone do not enforce these laws, so you'll have to check them yourself. newtype Equivalence a = Equivalence { getEquivalence :: a -> a -> Bool }-#ifdef LANGUAGE_DeriveDataTypeable- deriving Typeable-#endif -- | Equivalence relations are 'Contravariant', because you can -- apply the contramapped function to each input to the equivalence@@ -387,10 +333,8 @@ instance Contravariant Equivalence where contramap f g = Equivalence $ on (getEquivalence g) f -#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711 instance Semigroup (Equivalence a) where Equivalence p <> Equivalence q = Equivalence $ \a b -> p a b && q a b-#endif instance Monoid (Equivalence a) where mempty = Equivalence (\_ _ -> True)@@ -407,9 +351,6 @@ -- | Dual function arrows. newtype Op a b = Op { getOp :: b -> a }-#ifdef LANGUAGE_DeriveDataTypeable- deriving Typeable-#endif instance Category Op where id = Op id@@ -418,16 +359,13 @@ instance Contravariant (Op a) where contramap f g = Op (getOp g . f) -#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711 instance Semigroup a => Semigroup (Op a b) where Op p <> Op q = Op $ \a -> p a <> q a-#endif instance Monoid a => Monoid (Op a b) where mempty = Op (const mempty) mappend (Op p) (Op q) = Op $ \a -> mappend (p a) (q a) -#if MIN_VERSION_base(4,5,0) instance Num a => Num (Op a b) where Op f + Op g = Op $ \a -> f a + g a Op f * Op g = Op $ \a -> f a * g a@@ -460,4 +398,3 @@ acosh (Op f) = Op $ acosh . f Op f ** Op g = Op $ \a -> f a ** g a logBase (Op f) (Op g) = Op $ \a -> logBase (f a) (g a)-#endif
src/Data/Functor/Contravariant/Compose.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif -- | -- Module : Data.Functor.Contravariant.Compose -- Copyright : (c) Edward Kmett 2010@@ -22,10 +18,6 @@ ) where import Control.Arrow--#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Data.Functor.Contravariant import Data.Functor.Contravariant.Divisible
src/Data/Functor/Contravariant/Divisible.hs view
@@ -1,13 +1,9 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE TypeOperators #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif #if !(MIN_VERSION_transformers(0,6,0))-{-# OPTIONS_GHC -fno-warn-deprecations #-}+{-# OPTIONS_GHC -Wno-deprecations #-} #endif -----------------------------------------------------------------------------@@ -58,33 +54,22 @@ import Data.Functor.Contravariant import Data.Functor.Product import Data.Functor.Reverse+import Data.Monoid (Alt(..))+import Data.Proxy import Data.Void +import GHC.Generics+ #if !(MIN_VERSION_transformers(0,6,0)) import Control.Monad.Trans.Error import Control.Monad.Trans.List import Data.Either #endif -#if MIN_VERSION_base(4,8,0)-import Data.Monoid (Alt(..))-#else-import Data.Monoid (Monoid(..))-#endif--#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged)-import Data.Proxy-#endif- #ifdef MIN_VERSION_StateVar import Data.StateVar #endif -#if __GLASGOW_HASKELL__ >= 702-#define GHC_GENERICS-import GHC.Generics-#endif- -------------------------------------------------------------------------------- -- * Contravariant Applicative --------------------------------------------------------------------------------@@ -214,13 +199,10 @@ divide _ (Const a) (Const b) = Const (mappend a b) conquer = Const mempty -#if MIN_VERSION_base(4,8,0) instance Divisible f => Divisible (Alt f) where divide f (Alt l) (Alt r) = Alt $ divide f l r conquer = Alt conquer-#endif -#ifdef GHC_GENERICS instance Divisible U1 where divide _ U1 U1 = U1 conquer = U1@@ -240,7 +222,6 @@ instance (Applicative f, Divisible g) => Divisible (f :.: g) where divide f (Comp1 l) (Comp1 r) = Comp1 (divide f <$> l <*> r) conquer = Comp1 $ pure conquer-#endif instance Divisible f => Divisible (Backwards f) where divide f (Backwards l) (Backwards r) = Backwards $ divide f l r@@ -312,11 +293,9 @@ divide f (Reverse l) (Reverse r) = Reverse $ divide f l r conquer = Reverse conquer -#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged) instance Divisible Proxy where divide _ Proxy Proxy = Proxy conquer = Proxy-#endif #ifdef MIN_VERSION_StateVar instance Divisible SettableStateVar where@@ -436,13 +415,10 @@ lose f = Op $ absurd . f choose f (Op g) (Op h) = Op $ either g h . f -#if MIN_VERSION_base(4,8,0) instance Decidable f => Decidable (Alt f) where lose = Alt . lose choose f (Alt l) (Alt r) = Alt $ choose f l r-#endif -#ifdef GHC_GENERICS instance Decidable U1 where lose _ = U1 choose _ U1 U1 = U1@@ -462,7 +438,6 @@ instance (Applicative f, Decidable g) => Decidable (f :.: g) where lose = Comp1 . pure . lose choose f (Comp1 l) (Comp1 r) = Comp1 (choose f <$> l <*> r)-#endif instance Decidable f => Decidable (Backwards f) where lose = Backwards . lose@@ -557,11 +532,9 @@ lazyFst :: (a, b) -> a lazyFst ~(a, _) = a -#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged) instance Decidable Proxy where lose _ = Proxy choose _ Proxy Proxy = Proxy-#endif #ifdef MIN_VERSION_StateVar instance Decidable SettableStateVar where
src/Data/Functor/Contravariant/Generic.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE FlexibleInstances #-}@@ -11,13 +7,9 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE FlexibleContexts #-}-#if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-}-#endif {-# LANGUAGE TypeFamilies #-}-#if __GLASGOW_HASKELL__ >= 708 {-# LANGUAGE EmptyCase #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Contravariant.Generic@@ -165,11 +157,7 @@ gdeciding1 p q r = gchoose (gdeciding1 p q r) (gdeciding1 p q r) absurd1 :: V1 a -> b-#if defined(HLINT) || (__GLASGOW_HASKELL__ < 708)-absurd1 x = x `seq` error "impossible"-#else absurd1 x = case x of-#endif glose :: Decidable f => f (V1 a) glose = lose absurd1