packages feed

some 1.0.4 → 1.0.4.1

raw patch · 11 files changed

+110/−197 lines, 11 filesdep −semigroupsdep −transformersdep −transformers-compatdep ~basedep ~deepseq

Dependencies removed: semigroups, transformers, transformers-compat, type-equality

Dependency ranges changed: base, deepseq

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+# 1.0.4.1++- Drop support for GHC before 8.6+ # 1.0.4  - Add instances for `(:~~:)`
some.cabal view
@@ -1,5 +1,5 @@ name:               some-version:            1.0.4+version:            1.0.4.1 cabal-version:      >=1.10 build-type:         Simple author:@@ -24,21 +24,12 @@   If you are unsure which variant to use, use the one in "Data.Some" module.  tested-with:-  GHC ==7.0.4-   || ==7.2.2-   || ==7.4.2-   || ==7.6.3-   || ==7.8.4-   || ==7.10.3-   || ==8.0.2-   || ==8.2.2-   || ==8.4.4-   || ==8.6.5+  GHC ==8.6.5    || ==8.8.4    || ==8.10.4-   || ==9.0.1-   || ==9.2.3-   || ==9.4.1+   || ==9.0.2+   || ==9.2.4+   || ==9.4.2  extra-source-files: ChangeLog.md @@ -73,17 +64,8 @@    other-modules:    Data.GADT.Internal   build-depends:-      base     >=4.3     && <4.17-    , deepseq  >=1.3.0.0 && <1.5--  if !impl(ghc >=8.2)-    build-depends: type-equality >=1 && <1.1--  if !impl(ghc >=8.0)-    build-depends:-        semigroups           >=0.18.5 && <0.21-      , transformers         >=0.3    && <0.7-      , transformers-compat  >=0.6    && <0.8+      base     >=4.12    && <4.18+    , deepseq  >=1.4.4.0 && <1.5    if impl(ghc >=9.0)     -- these flags may abort compilation with GHC-8.10
src/Data/GADT/Compare.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE CPP         #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe        #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif module Data.GADT.Compare (     -- * Equality     GEq (..),
src/Data/GADT/DeepSeq.hs view
@@ -1,43 +1,24 @@-{-# LANGUAGE CPP         #-}-{-# LANGUAGE GADTs       #-}-{-# LANGUAGE TypeOperators       #-}-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds   #-}-#endif+{-# LANGUAGE CPP                      #-}+{-# LANGUAGE GADTs                    #-}+{-# LANGUAGE PolyKinds                #-}+{-# LANGUAGE Safe                     #-}+{-# LANGUAGE TypeOperators            #-} #if __GLASGOW_HASKELL__ >= 810 {-# LANGUAGE StandaloneKindSignatures #-} #endif-#if (__GLASGOW_HASKELL__ >= 704 && __GLASGOW_HASKELL__ < 707) || __GLASGOW_HASKELL__ >= 801-{-# LANGUAGE Safe        #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif module Data.GADT.DeepSeq (     GNFData (..),     ) where  import Data.Functor.Product (Product (..)) import Data.Functor.Sum     (Sum (..))-import Data.Type.Equality   ((:~:) (..))--#if MIN_VERSION_base(4,6,0)-import GHC.Generics         ((:+:) (..), (:*:) (..))-#endif--#if MIN_VERSION_base(4,9,0)-#if MIN_VERSION_base(4,10,0)-import  Data.Type.Equality ((:~~:) (..))-#else-import  Data.Type.Equality.Hetero ((:~~:) (..))-#endif-#endif+import Data.Type.Equality   ((:~:) (..), (:~~:) (..))+import GHC.Generics         ((:*:) (..), (:+:) (..)) -#if MIN_VERSION_base(4,10,0)-import qualified Type.Reflection    as TR-#endif+import qualified Type.Reflection as TR  #if __GLASGOW_HASKELL__ >= 810-import Data.Kind (Type, Constraint)+import Data.Kind (Constraint, Type) #endif  #if __GLASGOW_HASKELL__ >= 810@@ -54,27 +35,21 @@     grnf (InL x) = grnf x     grnf (InR y) = grnf y -#if MIN_VERSION_base(4,6,0) instance (GNFData a, GNFData b) => GNFData (a :*: b) where     grnf (a :*: b) = grnf a `seq` grnf b  instance (GNFData a, GNFData b) => GNFData (a :+: b) where     grnf (L1 x) = grnf x     grnf (R1 y) = grnf y-#endif  -- | @since 1.0.3 instance GNFData ((:~:) a) where     grnf Refl = () -#if MIN_VERSION_base(4,9,0) -- | @since 1.0.4 instance GNFData ((:~~:) a) where     grnf HRefl = ()-#endif -#if MIN_VERSION_base(4,10,0) -- | @since 1.0.3 instance GNFData TR.TypeRep where     grnf = TR.rnfTypeRep-#endif
src/Data/GADT/Internal.hs view
@@ -1,68 +1,37 @@-{-# LANGUAGE CPP                 #-}-{-# LANGUAGE DeriveDataTypeable  #-}-{-# LANGUAGE GADTs               #-}-{-# LANGUAGE RankNTypes          #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeOperators       #-}-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds           #-}-#endif-#if __GLASGOW_HASKELL__ >= 708-{-# LANGUAGE RoleAnnotations #-}-#endif+{-# LANGUAGE CPP                      #-}+{-# LANGUAGE GADTs                    #-}+{-# LANGUAGE PolyKinds                #-}+{-# LANGUAGE RankNTypes               #-}+{-# LANGUAGE RoleAnnotations          #-}+{-# LANGUAGE Safe                     #-}+{-# LANGUAGE ScopedTypeVariables      #-}+{-# LANGUAGE TypeOperators            #-} #if __GLASGOW_HASKELL__ >= 810 {-# LANGUAGE StandaloneKindSignatures #-} #endif-#if __GLASGOW_HASKELL__ >= 800 && __GLASGOW_HASKELL__ < 805-{-# LANGUAGE TypeInType #-}-#endif-#if (__GLASGOW_HASKELL__ >= 704 && __GLASGOW_HASKELL__ < 707) || __GLASGOW_HASKELL__ >= 801-{-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy         #-}-#endif module Data.GADT.Internal where  import Control.Applicative  (Applicative (..)) import Data.Functor.Product (Product (..)) import Data.Functor.Sum     (Sum (..))+import Data.Kind            (Type) import Data.Maybe           (isJust, isNothing) import Data.Monoid          (Monoid (..)) import Data.Semigroup       (Semigroup (..))-import Data.Type.Equality   ((:~:) (..))-#if MIN_VERSION_base(4,6,0)-import GHC.Generics         ((:+:) (..), (:*:) (..))-#endif--#if __GLASGOW_HASKELL__ >=708-import Data.Typeable (Typeable)-#endif--#if MIN_VERSION_base(4,9,0)-#if MIN_VERSION_base(4,10,0)-import  Data.Type.Equality ((:~~:) (..))-#else-import  Data.Type.Equality.Hetero ((:~~:) (..))-#endif-#endif--#if MIN_VERSION_base(4,10,0)-import           Data.Type.Equality (testEquality)-import qualified Type.Reflection    as TR-#endif+import Data.Type.Equality   (TestEquality (..), (:~:) (..), (:~~:) (..))+import GHC.Generics         ((:*:) (..), (:+:) (..)) -#if __GLASGOW_HASKELL__ >= 800-import Data.Kind (Type)-#endif+import qualified Type.Reflection as TR  #if __GLASGOW_HASKELL__ >= 810 import Data.Kind (Constraint) #endif  -- $setup--- >>> :set -XKindSignatures -XGADTs -XTypeOperators+-- >>> :set -XKindSignatures -XGADTs -XTypeOperators -XStandaloneDeriving -XQuantifiedConstraints -- >>> import Data.Type.Equality -- >>> import Data.Functor.Sum+-- >>> import Data.Maybe (isJust, isNothing) -- >>> import GHC.Generics  -- |'Show'-like class for 1-type-parameter GADTs.  @GShow t => ...@ is equivalent to something@@ -92,16 +61,12 @@ instance GShow ((:~:) a) where     gshowsPrec _ Refl = showString "Refl" -#if MIN_VERSION_base(4,9,0) -- | @since 1.0.4 instance GShow ((:~~:) a) where     gshowsPrec _ HRefl = showString "HRefl"-#endif -#if MIN_VERSION_base(4,10,0) instance GShow TR.TypeRep where     gshowsPrec = showsPrec-#endif  -- -- | >>> gshow (InL Refl :: Sum ((:~:) Int) ((:~:) Bool) Int)@@ -120,7 +85,6 @@         . showChar ' '         . gshowsPrec 11 y -#if MIN_VERSION_base(4,6,0) -- -- | >>> gshow (L1 Refl :: ((:~:) Int :+: (:~:) Bool) Int) -- "L1 Refl"@@ -140,7 +104,6 @@         $ gshowsPrec 6 x         . showString " :*: "         . gshowsPrec 6 y-#endif  -- |@GReadS t@ is equivalent to @ReadS (forall b. (forall a. t a -> b) -> b)@, which is -- in turn equivalent to @ReadS (Exists t)@ (with @data Exists t where Exists :: t a -> Exists t@)@@ -194,14 +157,12 @@         | ("Refl", t) <- lex s         ]) -#if MIN_VERSION_base(4,9,0) -- | @since 1.0.4 instance k1 ~ k2 => GRead ((:~~:) (a :: k1) :: k2 -> Type) where     greadsPrec _ = readParen False (\s ->         [ (S $ \k -> k (HRefl :: a :~~: a), t)         | ("HRefl", t) <- lex s         ])-#endif  instance (GRead a, GRead b) => GRead (Sum a b) where     greadsPrec d s =@@ -215,7 +176,6 @@                     | ("InR", s2) <- lex s1                     , (r, t) <- greadsPrec 11 s2 ]) s -#if MIN_VERSION_base(4,6,0) -- | @since 1.0.4 instance (GRead a, GRead b) => GRead (a :+: b) where     greadsPrec d s =@@ -228,7 +188,6 @@             (\s1 -> [ (S $ \k -> withSome r (k . R1), t)                     | ("R1", s2) <- lex s1                     , (r, t) <- greadsPrec 11 s2 ]) s-#endif  ------------------------------------------------------------------------------- -- GEq@@ -237,6 +196,75 @@ -- |A class for type-contexts which contain enough information -- to (at least in some cases) decide the equality of types -- occurring within them.+--+-- This class is sometimes confused with 'TestEquality' from base.+-- 'TestEquality' only checks /type equality/.+--+-- Consider+--+-- >>> data Tag a where TagInt1 :: Tag Int; TagInt2 :: Tag Int+--+-- The correct @'TestEquality' Tag@ instance is+--+-- >>> :{+-- instance TestEquality Tag where+--     testEquality TagInt1 TagInt1 = Just Refl+--     testEquality TagInt1 TagInt2 = Just Refl+--     testEquality TagInt2 TagInt1 = Just Refl+--     testEquality TagInt2 TagInt2 = Just Refl+-- :}+--+-- While we can define+--+-- @+-- instance 'GEq' Tag where+--    'geq' = 'testEquality'+-- @+--+-- this will mean we probably want to have+--+-- @+-- instance 'Eq' Tag where+--    _ '==' _ = True+-- @+--+-- /Note:/ In the future version of @some@ package (to be released around GHC-9.6 / 9.8) the+-- @forall a. Eq (f a)@ constraint will be added as a constraint to 'GEq',+-- with a law relating 'GEq' and 'Eq':+--+-- @+-- 'geq' x y = Just Refl   ⇒  x == y = True        ∀ (x :: f a) (y :: f b)+-- x == y                ≡  isJust ('geq' x y)     ∀ (x, y :: f a)+-- @+--+-- So, the more useful @'GEq' Tag@ instance would differentiate between+-- different constructors:+--+-- >>> :{+-- instance GEq Tag where+--     geq TagInt1 TagInt1 = Just Refl+--     geq TagInt1 TagInt2 = Nothing+--     geq TagInt2 TagInt1 = Nothing+--     geq TagInt2 TagInt2 = Just Refl+-- :}+--+-- which is consistent with a derived 'Eq' instance for 'Tag'+--+-- >>> deriving instance Eq (Tag a)+--+-- Note that even if @a ~ b@, the @'geq' (x :: f a) (y :: f b)@ may+-- be 'Nothing' (when value terms are inequal).+--+-- The consistency of 'GEq' and 'Eq' is easy to check by exhaustion:+--+-- >>> let checkFwdGEq :: (forall a. Eq (f a), GEq f) => f a -> f b -> Bool; checkFwdGEq x y = case geq x y of Just Refl -> x == y; Nothing -> True+-- >>> (checkFwdGEq TagInt1 TagInt1, checkFwdGEq TagInt1 TagInt2, checkFwdGEq TagInt2 TagInt1, checkFwdGEq TagInt2 TagInt2)+-- (True,True,True,True)+--+-- >>> let checkBwdGEq :: (Eq (f a), GEq f) => f a -> f a -> Bool; checkBwdGEq x y = if x == y then isJust (geq x y) else isNothing (geq x y)+-- >>> (checkBwdGEq TagInt1 TagInt1, checkBwdGEq TagInt1 TagInt2, checkBwdGEq TagInt2 TagInt1, checkBwdGEq TagInt2 TagInt2)+-- (True,True,True,True)+-- #if __GLASGOW_HASKELL__ >= 810 type GEq :: (k -> Type) -> Constraint #endif@@ -280,11 +308,9 @@ instance GEq ((:~:) a) where     geq (Refl :: a :~: b) (Refl :: a :~: c) = Just (Refl :: b :~: c) -#if MIN_VERSION_base(4,9,0) -- | @since 1.0.4 instance GEq ((:~~:) a) where     geq (HRefl :: a :~~: b) (HRefl :: a :~~: c) = Just (Refl :: b :~: c)-#endif  instance (GEq a, GEq b) => GEq (Sum a b) where     geq (InL x) (InL y) = geq x y@@ -297,7 +323,6 @@         Refl <- geq y y'         return Refl -#if MIN_VERSION_base(4,6,0) -- | @since 1.0.4 instance (GEq f, GEq g) => GEq (f :+: g) where   geq (L1 x) (L1 y) = geq x y@@ -310,12 +335,9 @@         Refl <- geq x x'         Refl <- geq y y'         return Refl-#endif -#if MIN_VERSION_base(4,10,0) instance GEq TR.TypeRep where     geq = testEquality-#endif  ------------------------------------------------------------------------------- -- GCompare@@ -357,9 +379,6 @@     GLT :: GOrdering a b     GEQ :: GOrdering t t     GGT :: GOrdering a b-#if __GLASGOW_HASKELL__ >=708-  deriving Typeable-#endif  -- |TODO: Think of a better name --@@ -402,13 +421,10 @@ instance GCompare ((:~:) a) where     gcompare Refl Refl = GEQ -#if MIN_VERSION_base(4,9,0) -- | @since 1.0.4 instance GCompare ((:~~:) a) where     gcompare HRefl HRefl = GEQ-#endif -#if MIN_VERSION_base(4,10,0) instance GCompare TR.TypeRep where     gcompare t1 t2 =       case testEquality t1 t2 of@@ -420,7 +436,6 @@             EQ -> error "impossible: 'testEquality' and 'compare' \                         \are inconsistent for TypeRep; report this \                         \as a GHC bug"-#endif  defaultCompare :: GCompare f => f a -> f b -> Ordering defaultCompare x y = weakenOrdering (gcompare x y)@@ -440,7 +455,6 @@             GEQ -> GEQ             GGT -> GGT -#if MIN_VERSION_base(4,6,0) -- | @since 1.0.4 instance (GCompare f, GCompare g) => GCompare (f :+: g) where     gcompare (L1 x) (L1 y) = gcompare x y@@ -457,7 +471,6 @@             GLT -> GLT             GEQ -> GEQ             GGT -> GGT-#endif  ------------------------------------------------------------------------------- -- Some@@ -513,9 +526,7 @@       withSome :: forall r. (forall a. tag a -> r) -> r     } -#if __GLASGOW_HASKELL__ >= 708 type role Some representational-#endif  -- | Constructor. mkSome :: tag a -> Some tag
src/Data/GADT/Show.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE CPP         #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe        #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif module Data.GADT.Show (     -- * Showing     GShow  (..),
src/Data/Some.hs view
@@ -1,18 +1,10 @@ {-# LANGUAGE CPP         #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe        #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif -- | An existential type. -- -- The constructor is exported only on GHC-8 and later. module Data.Some (-#if __GLASGOW_HASKELL__ >= 801 Some(Some),-#else-Some,-#endif mkSome, withSome, withSomeM,
src/Data/Some/Church.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE CPP         #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe        #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif module Data.Some.Church (     Some(..),     mkSome,
src/Data/Some/GADT.hs view
@@ -1,20 +1,12 @@-{-# LANGUAGE CPP         #-}-{-# LANGUAGE GADTs       #-}-{-# LANGUAGE RankNTypes  #-}-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds   #-}-#endif-#if __GLASGOW_HASKELL__ >= 708-{-# LANGUAGE RoleAnnotations #-}-#endif+{-# LANGUAGE CPP                      #-}+{-# LANGUAGE GADTs                    #-}+{-# LANGUAGE PolyKinds                #-}+{-# LANGUAGE RankNTypes               #-}+{-# LANGUAGE RoleAnnotations          #-}+{-# LANGUAGE Safe                     #-} #if __GLASGOW_HASKELL__ >= 810 {-# LANGUAGE StandaloneKindSignatures #-} #endif-#if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe        #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif module Data.Some.GADT (     Some(Some),     mkSome,@@ -91,9 +83,7 @@ data Some tag where     Some :: tag a -> Some tag -#if __GLASGOW_HASKELL__ >= 708 type role Some representational-#endif  -- | Constructor. mkSome :: tag a -> Some tag
src/Data/Some/Newtype.hs view
@@ -1,27 +1,15 @@ {-# LANGUAGE CPP             #-} {-# LANGUAGE GADTs           #-} {-# LANGUAGE RankNTypes      #-}-#if __GLASGOW_HASKELL__ >= 801 {-# LANGUAGE PatternSynonyms #-}-#endif-#if __GLASGOW_HASKELL__ >= 708 {-# LANGUAGE RoleAnnotations #-}-#endif-#if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds       #-}-#endif+{-# LANGUAGE Trustworthy     #-} #if __GLASGOW_HASKELL__ >= 810 {-# LANGUAGE StandaloneKindSignatures #-} #endif-#if __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy     #-}-#endif module Data.Some.Newtype (-#if __GLASGOW_HASKELL__ >= 801     Some(Some),-#else-    Some,-#endif     mkSome,     withSome,     withSomeM,@@ -96,23 +84,12 @@ #endif newtype Some tag = UnsafeSome (tag Any) -#if __GLASGOW_HASKELL__ >= 708 type role Some representational-#endif  -#if __GLASGOW_HASKELL__ >= 801 {-# COMPLETE Some #-} pattern Some :: tag a -> Some tag-#if __GLASGOW_HASKELL__ >= 802 pattern Some x <- UnsafeSome x   where Some x = UnsafeSome ((unsafeCoerce :: tag a -> tag Any) x)-#else--- There was a bug type checking pattern synonyms that prevented the--- obvious thing from working.-pattern Some x <- UnsafeSome ((unsafeCoerce :: tag Any -> tag a) -> x)-  where Some x = UnsafeSome ((unsafeCoerce :: tag a -> tag Any) x)-#endif-#endif  -- | Constructor. mkSome :: tag a -> Some tag
test/HKD.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP           #-} {-# LANGUAGE GADTs         #-} {-# LANGUAGE RankNTypes    #-} {-# LANGUAGE TypeOperators #-}@@ -22,13 +21,8 @@   G.Some mx -> () <$ mx  newtype_ftraverse_ :: (FFoldable t, Applicative m) => (forall a. f a -> m b) -> t f -> m ()-#if __GLASGOW_HASKELL__ >= 801 newtype_ftraverse_ k tf = case ffoldMap (N.Some . k) tf of   N.Some mx -> () <$ mx-#else-newtype_ftraverse_ k tf = N.withSome (ffoldMap (N.mkSome . k) tf) $-  \mx -> () <$ mx-#endif  church_ftraverse_ :: (FFoldable t, Applicative m) => (forall a. f a -> m b) -> t f -> m () church_ftraverse_ k tf = C.withSome (ffoldMap (C.mkSome . k) tf) $