packages feed

contravariant 1.2.1 → 1.2.2

raw patch · 4 files changed

+50/−6 lines, 4 filesdep +foreign-vardep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: foreign-var

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Data.Functor.Contravariant: instance [safe] Contravariant SettableVar

Files

CHANGELOG.markdown view
@@ -1,3 +1,7 @@+1.2.2+-----+* Added `foreign-var` support.+ 1.2.1 ----- * Added `phantom` to `Data.Functor.Contravariant`. This combinator was formerly called `coerce` in the `lens` package, but
contravariant.cabal view
@@ -1,6 +1,6 @@ name:          contravariant category:      Control, Data-version:       1.2.1+version:       1.2.2 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -37,19 +37,30 @@   default: True   manual: True +flag foreign-var+  description:+    You can disable the use of the `foreign-var` package on older versons of GHC using `-f-foreign-var`.+    .+    Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.+  default: True+  manual: True+ library   hs-source-dirs: src   build-depends:-    base < 5,-    transformers >= 0.2 && < 0.5,-    transformers-compat >= 0.3 && < 1,-    void >= 0.6 && < 1+    base                              < 5,+    transformers        >= 0.2 &&     < 0.5,+    transformers-compat >= 0.3 &&     < 1,+    void                >= 0.6 &&     < 1    if flag(tagged) && !impl(ghc >= 7.7)     build-depends: tagged >= 0.4.4 && < 1    if flag(semigroups)     build-depends: semigroups >= 0.15.2 && < 1++  if flag(foreign-var)+    build-depends: foreign-var < 1    if impl(ghc >= 7.4 && < 7.6)     build-depends: ghc-prim
src/Data/Functor/Contravariant.hs view
@@ -88,6 +88,10 @@  import Data.Void +#ifdef MIN_VERSION_foreign_var+import Foreign.Var+#endif+ #if __GLASGOW_HASKELL__ >= 702 #define GHC_GENERICS import GHC.Generics@@ -190,6 +194,12 @@ instance Contravariant f => Contravariant (Reverse f) where   contramap f = Reverse . contramap f . getReverse   {-# INLINE contramap #-}++#ifdef MIN_VERSION_foreign_var+instance Contravariant SettableVar where+  contramap f (SettableVar k) = SettableVar (k . f)+  {-# INLINE contramap #-}+#endif  #if (__GLASGOW_HASKELL__ >= 707) || defined(VERSION_tagged) instance Contravariant Proxy where
src/Data/Functor/Contravariant/Divisible.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Data.Functor.Contravariant.Divisible   (   -- * Contravariant Applicative@@ -10,6 +11,10 @@ import Data.Monoid import Data.Void +#if MIN_VERSION_foreign_var+import Foreign.Var+#endif+ -------------------------------------------------------------------------------- -- * Contravariant Applicative --------------------------------------------------------------------------------@@ -77,7 +82,6 @@ conquered :: Divisible f => f () conquered = conquer - -- | -- This is the divisible analogue of 'liftA'. It gives a viable default definition for 'contramap' in terms -- of the members of 'Divisible'.@@ -110,6 +114,13 @@     (b, c) -> g b && h c   conquer = Predicate $ const True +#if MIN_VERSION_foreign_var+instance Divisible SettableVar where+  divide k (SettableVar l) (SettableVar r) = SettableVar $ \ a -> case k a of+    (b, c) -> l b >> r c+  conquer = SettableVar $ \_ -> return ()+#endif+ -------------------------------------------------------------------------------- -- * Contravariant Alternative --------------------------------------------------------------------------------@@ -177,3 +188,11 @@ instance Monoid r => Decidable (Op r) where   lose f = Op $ absurd . f   choose f (Op g) (Op h) = Op $ either g h . f++#if MIN_VERSION_foreign_var+instance Decidable SettableVar where+  lose k = SettableVar (absurd . k)+  choose k (SettableVar l) (SettableVar r) = SettableVar $ \ a -> case k a of+    Left b -> l b+    Right c -> r c+#endif