these 1.2 → 1.2.1
raw patch · 5 files changed
+30/−214 lines, 5 filesdep −bifunctor-classes-compatdep −ghc-primdep −semigroupsdep ~assocdep ~basedep ~binary
Dependencies removed: bifunctor-classes-compat, ghc-prim, semigroups, transformers, transformers-compat
Dependency ranges changed: assoc, base, binary, deepseq, hashable
Files
- CHANGELOG.md +4/−0
- src/Data/Functor/These.hs +1/−86
- src/Data/These.hs +9/−57
- src/Data/These/Combinators.hs +0/−29
- these.cabal +16/−42
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 1.2.1++- Support GHC-8.6.5...GHC-9.10.1+ # 1.2 - Depend on `bifunctor-classes-compat` instead of `bifunctors`
src/Data/Functor/These.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveFunctor #-}@@ -7,18 +6,6 @@ {-# 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@@ -37,20 +24,12 @@ import qualified Data.Foldable as F import qualified Data.Foldable1 as F1 -#if MIN_VERSION_deepseq(1,4,3) import Control.DeepSeq (NFData (..), NFData1 (..))-#else-import Control.DeepSeq (NFData (..))-#endif -#if __GLASGOW_HASKELL__ >= 706 import GHC.Generics (Generic1)-#endif -#if __GLASGOW_HASKELL__ >= 708 import Data.Data (Data) import Data.Typeable (Typeable)-#endif ------------------------------------------------------------------------------- -- These1@@ -60,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'@@ -82,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@@ -108,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@@ -139,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@@ -173,22 +106,6 @@ (y, s3) <- liftReadsPrec rp rl 11 s2 return (These1 x y, s3) _ -> []-#else- readsPrec1 d = readParen (d > 10) $ \s0 -> do- (t, s1) <- lex s0- case t of- "This1" -> do- (x, s2) <- readsPrec1 11 s1- return (This1 x, s2)- "That1" -> do- (y, s2) <- readsPrec1 11 s1- return (That1 y, s2)- "These1" -> do- (x, s2) <- readsPrec1 11 s1- (y, s3) <- readsPrec1 11 s2- return (These1 x y, s3)- _ -> []-#endif ------------------------------------------------------------------------------- -- Eq, Ord, Show, Read@@ -248,13 +165,11 @@ -- 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-#endif -- | Available always --
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(..) @@ -41,48 +27,32 @@ ) 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 (..))@@ -103,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@@ -293,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'@@ -360,17 +325,6 @@ 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 -------------------------------------------------------------------------------@@ -409,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@@ -421,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,10 +86,8 @@ 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@@ -127,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. --@@ -144,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,6 +1,6 @@ cabal-version: >=1.10 name: these-version: 1.2+version: 1.2.1 synopsis: An either-or-both data type. homepage: https://github.com/haskellari/these license: BSD3@@ -31,21 +31,15 @@ * <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.4- || ==8.10.7- || ==9.0.2- || ==9.2.7- || ==9.4.4- || ==9.6.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@@ -54,11 +48,7 @@ library default-language: Haskell2010- ghc-options: -Wall-- if impl(ghc >=8.0)- ghc-options: -Wno-trustworthy-safe-+ ghc-options: -Wall -Wno-trustworthy-safe hs-source-dirs: src exposed-modules: Data.Functor.These@@ -67,34 +57,18 @@ -- ghc boot libs build-depends:- base >=4.5.1.0 && <4.19- , 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 -- 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.2- , hashable >=1.2.7.0 && <1.5-- if impl(ghc <7.5)- build-depends: ghc-prim+ assoc >=1.1.1 && <1.2+ , hashable >=1.4.4.0 && <1.5 if !impl(ghc >=9.6) build-depends: foldable1-classes-compat >=0.1 && <0.2-- if !impl(ghc >=8.2)- build-depends: bifunctor-classes-compat >=0.1 && <0.2-- if !impl(ghc >=8.0)- build-depends:- semigroups >=0.18.5 && <0.21- , transformers >=0.3.0.0 && <0.7- , transformers-compat >=0.6.5 && <0.8-- -- Ensure Data.Functor.Classes is always available- if impl(ghc >=7.10)- build-depends: transformers >=0.4.2.0 x-docspec-extra-packages: lens