packages feed

these 1.1.1.1 → 1.2.1

raw patch · 5 files changed

Files

CHANGELOG.md view
@@ -1,3 +1,21 @@+# 1.2.1++- Support GHC-8.6.5...GHC-9.10.1++# 1.2++- Depend on `bifunctor-classes-compat` instead of `bifunctors`+  See changelog note in `bifunctors-5.6`: https://hackage.haskell.org/package/bifunctors-5.6/changelog+  This is breaking change, but affects only GHC-8.0 and older users.+  In that case you should check various combinations of newer/older+  `bifunctors`, `these` (and e.g. `semialign`) packages.+- Depend on `assoc-1.1`. Since version 1.1 `assoc` has an almost trivial+  dependency footprint, so `these` depends on it unconditionally.+- Add `Bifoldable1 These` instance+- Add `Foldable1 (Data.Functor.These1 f g)` instance+- Change `Eq (These1 f g a)`, `Ord`, `Read`, `Show`, `NFData` instances similarly to how+  they are changed for `Product` and `Sum` in `base-4.18.0.0`.+ # 1.1.1.1  - Workaround GCC-4 C-preprocessor bug
src/Data/Functor/These.hs view
@@ -1,32 +1,19 @@-{-# LANGUAGE CPP                #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFoldable     #-} {-# LANGUAGE DeriveFunctor      #-} {-# LANGUAGE DeriveGeneric      #-} {-# LANGUAGE DeriveTraversable  #-}+{-# LANGUAGE FlexibleContexts   #-} {-# LANGUAGE OverloadedStrings  #-} {-# LANGUAGE Safe               #-}--#if MIN_VERSION_base(4,9,0)-#define LIFTED_FUNCTOR_CLASSES 1-#else-#if MIN_VERSION_transformers (0,5,0)-#define LIFTED_FUNCTOR_CLASSES 1-#else-#if MIN_VERSION_transformers_compat(0,5,0) && !MIN_VERSION_transformers(0,4,0)-#define LIFTED_FUNCTOR_CLASSES 1-#endif-#endif-#endif module Data.Functor.These (     These1 (..),     ) where  import Data.Foldable        (Foldable)-import Data.Functor.Classes-       (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..), compare1, eq1, readsPrec1,-       showsPrec1)+import Data.Functor.Classes (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..)) import Data.Monoid          (Monoid (..))+import Data.Semigroup       (Semigroup (..)) import Data.Traversable     (Traversable) import GHC.Generics         (Generic) import Prelude@@ -34,19 +21,15 @@        Show (..), lex, readParen, return, seq, showChar, showParen, showString,        ($), (&&), (.)) +import qualified Data.Foldable  as F+import qualified Data.Foldable1 as F1 -#if MIN_VERSION_deepseq(1,4,3)-import Control.DeepSeq (NFData (..), NFData1 (..), rnf1)-#endif+import Control.DeepSeq (NFData (..), NFData1 (..)) -#if __GLASGOW_HASKELL__ >= 706 import GHC.Generics (Generic1)-#endif -#if __GLASGOW_HASKELL__ >= 708 import Data.Data     (Data) import Data.Typeable (Typeable)-#endif  ------------------------------------------------------------------------------- -- These1@@ -56,21 +39,13 @@     = This1 (f a)     | That1 (g a)     | These1 (f a) (g a)-  deriving (Functor, Foldable, Traversable, Generic-#if __GLASGOW_HASKELL__ >= 706-    , Generic1-#endif-#if __GLASGOW_HASKELL__ >= 708-    , Typeable, Data-#endif-    )+  deriving (Functor, Foldable, Traversable, Generic, Generic1, Typeable, Data)  ------------------------------------------------------------------------------- -- Eq1 -------------------------------------------------------------------------------  instance (Eq1 f, Eq1 g) => Eq1 (These1 f g) where-#ifdef LIFTED_FUNCTOR_CLASSES     liftEq eq (This1 f)    (This1 f')     = liftEq eq f f'     liftEq eq (That1 g)    (That1 g')     = liftEq eq g g'     liftEq eq (These1 f g) (These1 f' g') = liftEq eq f f' && liftEq eq g g'@@ -78,22 +53,12 @@     liftEq _ This1  {} _ = False     liftEq _ That1  {} _ = False     liftEq _ These1 {} _ = False-#else-    eq1 (This1 f)    (This1 f')     = eq1 f f'-    eq1 (That1 g)    (That1 g')     = eq1 g g'-    eq1 (These1 f g) (These1 f' g') = eq1 f f' && eq1 g g' -    eq1 This1  {} _ = False-    eq1 That1  {} _ = False-    eq1 These1 {} _ = False-#endif- ------------------------------------------------------------------------------- -- Ord1 -------------------------------------------------------------------------------  instance (Ord1 f, Ord1 g) => Ord1 (These1 f g) where-#ifdef LIFTED_FUNCTOR_CLASSES     liftCompare  cmp (This1 f) (This1 f') = liftCompare cmp f f'     liftCompare _cmp (This1 _) _          = LT     liftCompare _cmp _         (This1 _)  = GT@@ -104,26 +69,12 @@      liftCompare  cmp (These1 f g) (These1 f' g') =         liftCompare cmp f f' `mappend` liftCompare cmp g g'-#else-    compare1 (This1 f) (This1 f') = compare1 f f'-    compare1 (This1 _) _          = LT-    compare1 _         (This1 _)  = GT -    compare1 (That1 g) (That1 g') = compare1 g g'-    compare1 (That1 _) _          = LT-    compare1 _         (That1 _)  = GT--    compare1  (These1 f g) (These1 f' g') =-        compare1 f f' `mappend` compare1 g g'-#endif-- ------------------------------------------------------------------------------- -- Show1 -------------------------------------------------------------------------------  instance (Show1 f, Show1 g) => Show1 (These1 f g) where-#ifdef LIFTED_FUNCTOR_CLASSES     liftShowsPrec sp sl d (This1 f) = showParen (d > 10)         $ showString "This1 "         . liftShowsPrec sp sl 11 f@@ -135,26 +86,12 @@         . liftShowsPrec sp sl 11 f         . showChar ' '         . liftShowsPrec sp sl 11 g-#else-    showsPrec1 d (This1 f) = showParen (d > 10)-        $ showString "This1 "-        . showsPrec1 11 f-    showsPrec1 d (That1 g) = showParen (d > 10)-        $ showString "That1 "-        . showsPrec1 11 g-    showsPrec1 d (These1 f g) = showParen (d > 10)-        $ showString "These1 "-        . showsPrec1 11 f-        . showChar ' '-        . showsPrec1 11 g-#endif  ------------------------------------------------------------------------------- -- Read1 -------------------------------------------------------------------------------  instance (Read1 f, Read1 g) => Read1 (These1 f g) where-#ifdef LIFTED_FUNCTOR_CLASSES     liftReadsPrec rp rl d = readParen (d > 10) $ \s0 -> do         (t, s1) <- lex s0         case t of@@ -169,44 +106,97 @@                 (y, s3) <- liftReadsPrec rp rl 11 s2                 return (These1 x y, s3)             _ -> []-#else-    readsPrec1 d = readParen (d > 10) $ \s0 -> do++-------------------------------------------------------------------------------+-- Eq, Ord, Show, Read+-------------------------------------------------------------------------------++instance (Eq   (f a), Eq   (g a), Eq a)   => Eq (These1 f g a) where+    This1 f    == This1 f'     = f == f'+    That1 g    == That1 g'     = g == g'+    These1 f g == These1 f' g' = f == f' && g == g'++    This1  {} == _ = False+    That1  {} == _ = False+    These1 {} == _ = False++instance (Ord  (f a), Ord  (g a), Ord a)  => Ord (These1 f g a) where+    compare (This1 f) (This1 f') = compare f f'+    compare (This1 _) _          = LT+    compare _         (This1 _)  = GT++    compare (That1 g) (That1 g') = compare g g'+    compare (That1 _) _          = LT+    compare _         (That1 _)  = GT++    compare  (These1 f g) (These1 f' g') =+        compare f f' `mappend` compare g g'++instance (Show (f a), Show (g a), Show a) => Show (These1 f g a) where+    showsPrec d (This1 f) = showParen (d > 10)+        $ showString "This1 "+        . showsPrec 11 f+    showsPrec d (That1 g) = showParen (d > 10)+        $ showString "That1 "+        . showsPrec 11 g+    showsPrec d (These1 f g) = showParen (d > 10)+        $ showString "These1 "+        . showsPrec 11 f+        . showChar ' '+        . showsPrec 11 g++instance (Read (f a), Read (g a), Read a) => Read (These1 f g a) where+    readsPrec d = readParen (d > 10) $ \s0 -> do         (t, s1) <- lex s0         case t of             "This1" -> do-                (x, s2) <- readsPrec1 11 s1+                (x, s2) <- readsPrec 11 s1                 return (This1 x, s2)             "That1" -> do-                (y, s2) <- readsPrec1 11 s1+                (y, s2) <- readsPrec 11 s1                 return (That1 y, s2)             "These1" -> do-                (x, s2) <- readsPrec1 11 s1-                (y, s3) <- readsPrec1 11 s2+                (x, s2) <- readsPrec 11 s1+                (y, s3) <- readsPrec 11 s2                 return (These1 x y, s3)             _ -> []-#endif  ---------------------------------------------------------------------------------- Eq, Ord, Show, Read----------------------------------------------------------------------------------instance (Eq1 f, Eq1 g, Eq a) => Eq (These1 f g a) where (==) = eq1-instance (Ord1 f, Ord1 g, Ord a) => Ord (These1 f g a) where compare = compare1-instance (Show1 f, Show1 g, Show a) => Show (These1 f g a) where showsPrec = showsPrec1-instance (Read1 f, Read1 g, Read a) => Read (These1 f g a) where readsPrec = readsPrec1--------------------------------------------------------------------------------- -- deepseq ------------------------------------------------------------------------------- -#if MIN_VERSION_deepseq(1,4,3) -- | This instance is available only with @deepseq >= 1.4.3.0@ instance (NFData1 f, NFData1 g) => NFData1 (These1 f g) where     liftRnf r (This1 x)    = liftRnf r x     liftRnf r (That1 y)    = liftRnf r y     liftRnf r (These1 x y) = liftRnf r x `seq` liftRnf r y --- | This instance is available only with @deepseq >= 1.4.3.0@-instance (NFData1 f, NFData1 g, NFData a) => NFData (These1 f g a) where-    rnf = rnf1-#endif+-- | Available always+--+-- @since 1.2+instance (NFData (f a), NFData (g a), NFData a) => NFData (These1 f g a) where+    rnf (This1 x)    = rnf x+    rnf (That1 y)    = rnf y+    rnf (These1 x y) = rnf x `seq` rnf y++-------------------------------------------------------------------------------+-- foldable1+-------------------------------------------------------------------------------++-- | @since 1.2+instance (F1.Foldable1 f, F1.Foldable1 g) => F1.Foldable1 (These1 f g) where+    foldMap1 f (This1 x)    = F1.foldMap1 f x+    foldMap1 f (That1 y)    = F1.foldMap1 f y+    foldMap1 f (These1 x y) = F1.foldMap1 f x <> F1.foldMap1 f y++    foldrMap1 f g (This1 x)    = F1.foldrMap1 f g x+    foldrMap1 f g (That1 y)    = F1.foldrMap1 f g y+    foldrMap1 f g (These1 x y) = F.foldr g (F1.foldrMap1 f g y) x++    head (This1 x)    = F1.head x+    head (That1 y)    = F1.head y+    head (These1 x _) = F1.head x++    last (This1 x)    = F1.last x+    last (That1 y)    = F1.last y+    last (These1 _ y) = F1.last y
src/Data/These.hs view
@@ -1,22 +1,8 @@-{-# LANGUAGE CPP                #-}--- | The 'These' type and associated operations. Now enhanced with "Control.Lens" magic!+-- | The 'These' type and associated operations. {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric      #-} {-# LANGUAGE OverloadedStrings  #-} {-# LANGUAGE Safe               #-}--#if MIN_VERSION_base(4,9,0)-#define LIFTED_FUNCTOR_CLASSES 1-#else-#if MIN_VERSION_transformers(0,5,0)-#define LIFTED_FUNCTOR_CLASSES 1-#else-#if MIN_VERSION_transformers_compat(0,5,0) && !MIN_VERSION_transformers(0,4,0)-#define LIFTED_FUNCTOR_CLASSES 1-#endif-#endif-#endif- module Data.These (       These(..) @@ -33,7 +19,7 @@      -- * Distributivity     ---    -- | This distributivity combinators aren't isomorphisms!+    -- | These distributivity combinators aren't isomorphisms!     , distrThesePair     , undistrThesePair     , distrPairThese@@ -41,49 +27,36 @@     ) where  import Control.Applicative  (Applicative (..), (<$>))-import Control.DeepSeq      (NFData (..))+import Control.DeepSeq      (NFData (..), NFData1 (..), NFData2 (..)) import Data.Bifoldable      (Bifoldable (..))+import Data.Bifoldable1     (Bifoldable1 (..)) import Data.Bifunctor       (Bifunctor (..))+import Data.Bifunctor.Assoc (Assoc (..))+import Data.Bifunctor.Swap  (Swap (..)) import Data.Binary          (Binary (..)) import Data.Bitraversable   (Bitraversable (..)) import Data.Data            (Data, Typeable) import Data.Either          (partitionEithers) import Data.Foldable        (Foldable (..))+import Data.Functor.Classes+       (Eq1 (..), Eq2 (..), Ord1 (..), Ord2 (..), Read1 (..), Read2 (..),+       Show1 (..), Show2 (..)) import Data.Hashable        (Hashable (..)) import Data.Hashable.Lifted (Hashable1 (..), Hashable2 (..)) import Data.List.NonEmpty   (NonEmpty (..)) import Data.Monoid          (Monoid (..)) import Data.Semigroup       (Semigroup (..)) import Data.Traversable     (Traversable (..))-import GHC.Generics         (Generic)+import GHC.Generics         (Generic, Generic1) import Prelude        (Bool (..), Either (..), Eq (..), Functor (..), Int, Monad (..),        Ord (..), Ordering (..), Read (..), Show (..), fail, id, lex, readParen,        seq, showParen, showString, ($), (&&), (.)) -#if MIN_VERSION_deepseq(1,4,3)-import Control.DeepSeq (NFData1 (..), NFData2 (..))-#endif--#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif--#ifdef MIN_VERSION_assoc-import Data.Bifunctor.Assoc (Assoc (..))-import Data.Bifunctor.Swap  (Swap (..))-#endif--#ifdef LIFTED_FUNCTOR_CLASSES-import Data.Functor.Classes-       (Eq1 (..), Eq2 (..), Ord1 (..), Ord2 (..), Read1 (..), Read2 (..),-       Show1 (..), Show2 (..))-#else-import Data.Functor.Classes (Eq1 (..), Ord1 (..), Read1 (..), Show1 (..))-#endif- -- $setup -- >>> import Control.Lens+-- >>> import Data.List.NonEmpty (NonEmpty (..))+-- >>> import Prelude (Either (..), map, ($))  -- -------------------------------------------------------------------------- -- | The 'These' type represents values with two non-exclusive possibilities.@@ -100,11 +73,7 @@ --   For zipping and unzipping of structures with 'These' values, see --   "Data.Align". data These a b = This a | That b | These a b-  deriving (Eq, Ord, Read, Show, Typeable, Data, Generic-#if __GLASGOW_HASKELL__ >= 706-    , Generic1-#endif-    )+  deriving (Eq, Ord, Read, Show, Typeable, Data, Generic, Generic1)  ------------------------------------------------------------------------------- -- Eliminators@@ -216,8 +185,6 @@ -- Instances ------------------------------------------------------------------------------- -- instance (Semigroup a, Semigroup b) => Semigroup (These a b) where     This  a   <> This  b   = This  (a <> b)     This  a   <> That    y = These  a             y@@ -254,9 +221,15 @@  instance Bifoldable These where     bifold = these id id mappend+    bifoldMap f g = these f g (\x y -> mappend (f x) (g y))     bifoldr f g z = these (`f` z) (`g` z) (\x y -> x `f` (y `g` z))     bifoldl f g z = these (z `f`) (z `g`) (\x y -> (z `f` x) `g` y) +-- | @since 1.2+instance Bifoldable1 These where+    bifold1 = these id id (<>)+    bifoldMap1 f g = these f g (\x y -> f x <> g y)+ instance Bitraversable These where     bitraverse f _ (This x) = This <$> f x     bitraverse _ g (That x) = That <$> g x@@ -286,7 +259,6 @@ -- Data.Functor.Classes ------------------------------------------------------------------------------- -#ifdef LIFTED_FUNCTOR_CLASSES -- | @since 1.1.1 instance Eq2 These where   liftEq2 f _ (This a)    (This a')     = f a a'@@ -353,22 +325,10 @@ instance Read a => Read1 (These a) where   liftReadsPrec = liftReadsPrec2 readsPrec readList -#else--- | @since 1.1.1-instance Eq a   => Eq1   (These a) where eq1        = (==)--- | @since 1.1.1-instance Ord a  => Ord1  (These a) where compare1   = compare--- | @since 1.1.1-instance Show a => Show1 (These a) where showsPrec1 = showsPrec--- | @since 1.1.1-instance Read a => Read1 (These a) where readsPrec1 = readsPrec-#endif- ------------------------------------------------------------------------------- -- assoc ------------------------------------------------------------------------------- -#ifdef MIN_VERSION_assoc -- | @since 0.8 instance Swap These where     swap (This a)    = That a@@ -392,7 +352,6 @@     unassoc (These a (This b))    = This (These a b)     unassoc (These a (That c))    = These (This a) c     unassoc (These a (These b c)) = These (These a b) c-#endif  ------------------------------------------------------------------------------- -- deepseq@@ -404,7 +363,6 @@     rnf (That b)    = rnf b     rnf (These a b) = rnf a `seq` rnf b -#if MIN_VERSION_deepseq(1,4,3) -- | @since 1.1.1 instance NFData a => NFData1 (These a) where     liftRnf _rnfB (This a)    = rnf a@@ -416,7 +374,6 @@     liftRnf2  rnfA _rnfB (This a)    = rnfA a     liftRnf2 _rnfA  rnfB (That b)    = rnfB b     liftRnf2  rnfA  rnfB (These a b) = rnfA a `seq` rnfB b-#endif  ------------------------------------------------------------------------------- -- binary
src/Data/These/Combinators.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP         #-} {-# LANGUAGE Trustworthy #-} -- | This module provides --@@ -87,11 +86,12 @@ import Data.These import Prelude             (Bool (..), Maybe (..), curry, uncurry, (.)) -#ifdef MIN_VERSION_assoc import Data.Bifunctor.Assoc (assoc, unassoc) import Data.Bifunctor.Swap  (swap)-#endif +-- $setup+-- >>> import Data.These+ ------------------------------------------------------------------------------- -- bifunctors -------------------------------------------------------------------------------@@ -124,13 +124,7 @@ -- -- @since 0.8 swapThese :: These a b -> These b a-#ifdef MIN_VERSION_assoc swapThese = swap-#else-swapThese (This a)    = That a-swapThese (That b)    = This b-swapThese (These a b) = These b a-#endif  -- | 'These' is associative. --@@ -141,33 +135,13 @@ -- -- @since 0.8 assocThese :: These (These a b) c -> These a (These b c)-#ifdef MIN_VERSION_assoc assocThese = assoc-#else-assocThese (This (This a))       = This a-assocThese (This (That b))       = That (This b)-assocThese (That c)              = That (That c)-assocThese (These (That b) c)    = That (These b c)-assocThese (This (These a b))    = These a (This b)-assocThese (These (This a) c)    = These a (That c)-assocThese (These (These a b) c) = These a (These b c)-#endif  -- | 'These' is associative. See 'assocThese'. -- -- @since 0.8 unassocThese :: These a (These b c) -> These (These a b) c-#ifdef MIN_VERSION_assoc unassocThese = unassoc-#else-unassocThese (This a)              = This (This a)-unassocThese (That (This b))       = This (That b)-unassocThese (That (That c))       = That c-unassocThese (That (These b c))    = These (That b) c-unassocThese (These a (This b))    = This (These a b)-unassocThese (These a (That c))    = These (This a) c-unassocThese (These a (These b c)) = These (These a b) c-#endif  ------------------------------------------------------------------------------- -- preview
these.cabal view
@@ -1,8 +1,8 @@ cabal-version:      >=1.10 name:               these-version:            1.1.1.1+version:            1.2.1 synopsis:           An either-or-both data type.-homepage:           https://github.com/isomorphism/these+homepage:           https://github.com/haskellari/these license:            BSD3 license-file:       LICENSE author:             C. McCann, Oleg Grenrus@@ -31,35 +31,25 @@   * <http://hackage.haskell.org/package/monad-chronicle monad-chronicle> For transformers variant of @These@.  tested-with:-    GHC ==7.4.2-     || ==7.6.3-     || ==7.8.4-     || ==7.10.3-     || ==8.0.2-     || ==8.2.2-     || ==8.4.4-     || ==8.6.5-     || ==8.8.3-     || ==8.10.1-  , GHCJS ==8.4+  GHC ==8.6.5+   || ==8.8.4+   || ==8.10.7+   || ==9.0.2+   || ==9.2.8+   || ==9.4.8+   || ==9.6.5+   || ==9.8.2+   || ==9.10.1  source-repository head   type:     git-  location: https://github.com/isomorphism/these.git--flag assoc-  description: Build with assoc dependency-  manual:      True-  default:     True+  location: https://github.com/haskellari/these.git+  subdir:   these  library-  default-language: Haskell2010-  ghc-options:      -Wall--  if impl(ghc >=8.0)-    ghc-options: -Wno-trustworthy-safe--  hs-source-dirs:   src+  default-language:         Haskell2010+  ghc-options:              -Wall -Wno-trustworthy-safe+  hs-source-dirs:           src   exposed-modules:     Data.Functor.These     Data.These@@ -67,28 +57,18 @@    -- ghc boot libs   build-depends:-      base     >=4.5.1.0 && <4.15-    , binary   >=0.5.1.0 && <0.10-    , deepseq  >=1.3.0.0 && <1.5+      base     >=4.12.0.0 && <4.21+    , binary   >=0.8.6.0  && <0.10+    , deepseq  >=1.4.4.0  && <1.6    -- other dependencies-  build-depends:    hashable >=1.2.7.0 && <1.4--  if impl(ghc <7.5)-    build-depends: ghc-prim--  if !impl(ghc >=8.2)-    build-depends: bifunctors >=5.5.4 && <5.6--  if !impl(ghc >=8.0)-    build-depends:-        semigroups           >=0.18.5  && <0.20-      , transformers         >=0.3.0.0 && <0.6-      , transformers-compat  >=0.6.5   && <0.7+  -- note: we need to depend on assoc-1.1 to be sure that+  -- Bifunctor type class comes from bifunctor-classes-compat+  build-depends:+      assoc     >=1.1.1   && <1.2+    , hashable  >=1.4.4.0 && <1.5 -    -- Ensure Data.Functor.Classes is always available-    if impl(ghc >=7.10)-      build-depends: transformers >=0.4.2.0+  if !impl(ghc >=9.6)+    build-depends: foldable1-classes-compat >=0.1 && <0.2 -  if flag(assoc)-    build-depends: assoc >=1 && <1.1+  x-docspec-extra-packages: lens