some 1.0.2 → 1.0.3
raw patch · 6 files changed
+117/−11 lines, 6 filesdep ~basedep ~semigroupsdep ~transformers
Dependency ranges changed: base, semigroups, transformers, transformers-compat
Files
- ChangeLog.md +5/−0
- some.cabal +9/−4
- src/Data/GADT/DeepSeq.hs +31/−1
- src/Data/GADT/Internal.hs +37/−6
- src/Data/Some/GADT.hs +18/−0
- src/Data/Some/Newtype.hs +17/−0
ChangeLog.md view
@@ -1,3 +1,8 @@+# 1.0.3++- Make `GNFData` PolyKinded.+- Add `GNFData ((:~:) a)` and `GNFData TypeRep` instances+ # 1.0.2 - Explicitly mark `Data.Some` as `Safe`.
some.cabal view
@@ -1,5 +1,5 @@ name: some-version: 1.0.2+version: 1.0.3 stability: provisional cabal-version: >=1.10 build-type: Simple@@ -36,7 +36,8 @@ || ==8.4.4 || ==8.6.5 || ==8.8.4- || ==8.10.3+ || ==8.10.4+ || ==9.0.1 extra-source-files: ChangeLog.md @@ -59,11 +60,12 @@ if flag(newtype-unsafe) cpp-options: -DSOME_NEWTYPE + -- main module+ exposed-modules: Data.Some exposed-modules: Data.GADT.Compare Data.GADT.DeepSeq Data.GADT.Show- Data.Some Data.Some.Church Data.Some.GADT Data.Some.Newtype@@ -82,10 +84,13 @@ , transformers >=0.3 && <0.6 , transformers-compat >=0.6 && <0.7 - if impl(ghc >= 9.0)+ if impl(ghc >=9.0) -- these flags may abort compilation with GHC-8.10 -- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295 ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode++ if impl(ghc >=9.1)+ ghc-options: -Wmissing-kind-signatures test-suite hkd-example default-language: Haskell2010
src/Data/GADT/DeepSeq.hs view
@@ -1,5 +1,12 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE GADTs #-}+#if __GLASGOW_HASKELL__ >= 706+{-# LANGUAGE PolyKinds #-}+#endif+#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 #-}@@ -10,7 +17,20 @@ import Data.Functor.Product (Product (..)) import Data.Functor.Sum (Sum (..))+import Data.Type.Equality ((:~:) (..)) +#if MIN_VERSION_base(4,10,0)+import qualified Type.Reflection as TR+#endif++#if __GLASGOW_HASKELL__ >= 810+import Data.Kind (Type, Constraint)+#endif++#if __GLASGOW_HASKELL__ >= 810+type GNFData :: (k -> Type) -> Constraint+#endif+ class GNFData f where grnf :: f a -> () @@ -20,3 +40,13 @@ instance (GNFData a, GNFData b) => GNFData (Sum a b) where grnf (InL x) = grnf x grnf (InR y) = grnf y++-- | @since 1.0.3+instance GNFData ((:~:) a) where+ grnf Refl = ()++#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
@@ -7,15 +7,17 @@ #if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-} #endif-#if __GLASGOW_HASKELL__ >= 704-#define GHC __GLASGOW_HASKELL__-#if (GHC >= 704 && GHC <707) || GHC >= 801+#if __GLASGOW_HASKELL__ >= 708+{-# LANGUAGE RoleAnnotations #-}+#endif+#if __GLASGOW_HASKELL__ >= 810+{-# LANGUAGE StandaloneKindSignatures #-}+#endif+#if (__GLASGOW_HASKELL__ >= 704 && __GLASGOW_HASKELL__ < 707) || __GLASGOW_HASKELL__ >= 801 {-# LANGUAGE Safe #-}-#else+#elif __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} #endif-#undef GHC-#endif module Data.GADT.Internal where import Control.Applicative (Applicative (..))@@ -35,6 +37,10 @@ import qualified Type.Reflection as TR #endif +#if __GLASGOW_HASKELL__ >= 810+import Data.Kind (Type, Constraint)+#endif+ -- $setup -- >>> :set -XKindSignatures -XGADTs @@ -43,6 +49,9 @@ -- to write (or derive) an @instance Show (T a)@, and then simply say: -- -- > instance GShow t where gshowsPrec = showsPrec+#if __GLASGOW_HASKELL__ >= 810+type GShow :: (k -> Type) -> Constraint+#endif class GShow t where gshowsPrec :: Int -> t a -> ShowS @@ -79,6 +88,9 @@ -- |@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@)+#if __GLASGOW_HASKELL__ >= 810+type GReadS :: (k -> Type) -> Type+#endif type GReadS t = String -> [(Some t, String)] getGReadResult :: Some tag -> (forall a. tag a -> b) -> b@@ -90,6 +102,9 @@ -- |'Read'-like class for 1-type-parameter GADTs. Unlike 'GShow', this one cannot be -- mechanically derived from a 'Read' instance because 'greadsPrec' must choose the phantom -- type based on the 'String' being parsed.+#if __GLASGOW_HASKELL__ >= 810+type GRead :: (k -> Type) -> Constraint+#endif class GRead t where greadsPrec :: Int -> GReadS t @@ -139,6 +154,9 @@ -- |A class for type-contexts which contain enough information -- to (at least in some cases) decide the equality of types -- occurring within them.+#if __GLASGOW_HASKELL__ >= 810+type GEq :: (k -> Type) -> Constraint+#endif class GEq f where -- |Produce a witness of type-equality, if one exists. --@@ -219,6 +237,9 @@ -- |A type for the result of comparing GADT constructors; the type parameters -- of the GADT values being compared are included so that in the case where -- they are equal their parameter types can be unified.+#if __GLASGOW_HASKELL__ >= 810+type GOrdering :: k -> k -> Type+#endif data GOrdering a b where GLT :: GOrdering a b GEQ :: GOrdering t t@@ -259,6 +280,9 @@ -- |Type class for comparable GADT-like structures. When 2 things are equal, -- must return a witness that their parameter types are equal as well ('GEQ').+#if __GLASGOW_HASKELL__ >= 810+type GCompare :: (k -> Type) -> Constraint+#endif class GEq f => GCompare f where gcompare :: f a -> f b -> GOrdering a b @@ -343,10 +367,17 @@ -- >>> read "mkSome TagInt" :: Some Tag -- mkSome TagInt --+#if __GLASGOW_HASKELL__ >= 810+type Some :: (k -> Type) -> Type+#endif newtype Some tag = S { -- | Eliminator. 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/Some/GADT.hs view
@@ -4,6 +4,12 @@ #if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-} #endif+#if __GLASGOW_HASKELL__ >= 708+{-# LANGUAGE RoleAnnotations #-}+#endif+#if __GLASGOW_HASKELL__ >= 810+{-# LANGUAGE StandaloneKindSignatures #-}+#endif #if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-} #elif __GLASGOW_HASKELL__ >= 702@@ -24,10 +30,15 @@ import Data.Monoid (Monoid (..)) import Data.Semigroup (Semigroup (..)) +#if __GLASGOW_HASKELL__ >= 810+import Data.Kind (Type)+#endif+ import Data.GADT.Compare import Data.GADT.DeepSeq import Data.GADT.Show + -- $setup -- >>> :set -XKindSignatures -XGADTs @@ -73,8 +84,15 @@ -- >>> read "mkSome TagInt" :: Some Tag -- Some TagInt --+#if __GLASGOW_HASKELL__ >= 810+type Some :: (k -> Type) -> Type+#endif 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
@@ -4,9 +4,15 @@ #if __GLASGOW_HASKELL__ >= 801 {-# LANGUAGE PatternSynonyms #-} #endif+#if __GLASGOW_HASKELL__ >= 708+{-# LANGUAGE RoleAnnotations #-}+#endif #if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-} #endif+#if __GLASGOW_HASKELL__ >= 810+{-# LANGUAGE StandaloneKindSignatures #-}+#endif #if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} #endif@@ -31,6 +37,10 @@ import GHC.Exts (Any) import Unsafe.Coerce (unsafeCoerce) +#if __GLASGOW_HASKELL__ >= 810+import Data.Kind (Type)+#endif+ import Data.GADT.Compare import Data.GADT.DeepSeq import Data.GADT.Show@@ -80,7 +90,14 @@ -- >>> read "mkSome TagInt" :: Some Tag -- Some TagInt --+#if __GLASGOW_HASKELL__ >= 810+type Some :: (k -> Type) -> Type+#endif newtype Some tag = UnsafeSome (tag Any)++#if __GLASGOW_HASKELL__ >= 708+type role Some representational+#endif #if __GLASGOW_HASKELL__ >= 801 {-# COMPLETE Some #-}