tagged 0.8.8 → 0.8.9
raw patch · 5 files changed
+39/−439 lines, 5 filesdep −ghc-primdep −transformers-compatdep ~basedep ~template-haskelldep ~transformers
Dependencies removed: ghc-prim, transformers-compat
Dependency ranges changed: base, template-haskell, transformers
Files
- CHANGELOG.markdown +5/−0
- old/Data/Proxy.hs +0/−279
- src/Data/Proxy/TH.hs +5/−28
- src/Data/Tagged.hs +6/−89
- tagged.cabal +23/−43
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+0.8.9 [2024.12.03]+------------------+* Allow building with GHC 9.12.+* Drop support for GHC 7.10 and earlier.+ 0.8.8 [2023.08.08] ------------------ * Allow building with GHC 9.8.
− old/Data/Proxy.hs
@@ -1,279 +0,0 @@-{-# LANGUAGE CPP #-}-#ifdef LANGUAGE_DeriveDataTypeable-{-# LANGUAGE DeriveDataTypeable #-}-#endif-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE KindSignatures #-}-{-# LANGUAGE PolyKinds #-}-#endif-#if __GLASGOW_HASKELL__ >= 707-{-# LANGUAGE StandaloneDeriving #-}-#endif-#if __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE EmptyDataDecls #-}-{-# LANGUAGE Trustworthy #-}-{-# LANGUAGE TypeFamilies #-}-#endif-{-# OPTIONS_GHC -fno-warn-orphans #-}-------------------------------------------------------------------------------- |--- Module : Data.Proxy--- Copyright : 2009-2013 Edward Kmett--- License : BSD3------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : experimental--- Portability : portable------------------------------------------------------------------------------------module Data.Proxy- (- -- * Proxy values- Proxy(..)- , asProxyTypeOf- , KProxy(..)- ) where--import Control.Applicative (Applicative(..), Alternative(..))-import Control.Monad (MonadPlus(..))-#if MIN_VERSION_base(4,4,0)-import Control.Monad.Zip (MonadZip(..))-#endif-#ifdef MIN_VERSION_deepseq-import Control.DeepSeq (NFData(..))-#endif-#ifdef MIN_VERSION_transformers-import Data.Functor.Classes (Eq1(..), Ord1(..), Read1(..), Show1(..))-#endif-import Data.Traversable (Traversable(..))-import Data.Foldable (Foldable(..))-import Data.Ix (Ix(..))-import Data.Monoid-#ifdef __GLASGOW_HASKELL__-import GHC.Arr (unsafeIndex, unsafeRangeSize)-import Data.Data-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics hiding (Fixity(..))-#endif-#endif--#if __GLASGOW_HASKELL__ >= 707-deriving instance Typeable Proxy-#else-data Proxy s = Proxy-#if __GLASGOW_HASKELL__ >= 702- deriving Generic---- We have to implement the Generic1 instance manually due to an old--- bug in GHC 7.6. This is mostly copied from the output of------ deriving instance Generic1 Proxy------ Compiled with -ddump-deriv on a more recent GHC.-instance Generic1 Proxy where- type Rep1 Proxy = D1 ProxyMetaData (C1 ProxyMetaCons U1)- from1 Proxy = M1 (M1 U1)- to1 (M1 (M1 U1)) = Proxy--data ProxyMetaData-data ProxyMetaCons--instance Datatype ProxyMetaData where- datatypeName _ = "Proxy"- moduleName _ = "Data.Proxy"--instance Constructor ProxyMetaCons where- conName _ = "Proxy"-#endif-#endif--instance Eq (Proxy s) where- _ == _ = True--instance Ord (Proxy s) where- compare _ _ = EQ--instance Show (Proxy s) where- showsPrec _ _ = showString "Proxy"--instance Read (Proxy s) where- readsPrec _ = readParen False (\r -> [(Proxy, s) | ("Proxy",s) <- lex r ])--#ifdef __GLASGOW_HASKELL__-#if __GLASGOW_HASKELL__ < 707-instance Typeable1 Proxy where- typeOf1 _ = mkTyConApp proxyTyCon []--proxyTyCon :: TyCon-#if __GLASGOW_HASKELL__ < 704-proxyTyCon = mkTyCon "Data.Proxy.Proxy"-#else-proxyTyCon = mkTyCon3 "tagged" "Data.Proxy" "Proxy"-#endif-{-# NOINLINE proxyTyCon #-}-#endif--instance Data s => Data (Proxy s) where- gfoldl _ z _ = z Proxy- toConstr _ = proxyConstr- gunfold _ z c = case constrIndex c of- 1 -> z Proxy- _ -> error "gunfold"- dataTypeOf _ = proxyDataType- dataCast1 f = gcast1 f--proxyConstr :: Constr-proxyConstr = mkConstr proxyDataType "Proxy" [] Prefix-{-# NOINLINE proxyConstr #-}--proxyDataType :: DataType-proxyDataType = mkDataType "Data.Proxy.Proxy" [proxyConstr]-{-# NOINLINE proxyDataType #-}-#endif--instance Enum (Proxy s) where- succ _ = error "Proxy.succ"- pred _ = error "Proxy.pred"- fromEnum _ = 0- toEnum 0 = Proxy- toEnum _ = error "Proxy.toEnum: 0 expected"- enumFrom _ = [Proxy]- enumFromThen _ _ = [Proxy]- enumFromThenTo _ _ _ = [Proxy]- enumFromTo _ _ = [Proxy]--instance Ix (Proxy s) where- range _ = [Proxy]- index _ _ = 0- inRange _ _ = True- rangeSize _ = 1-#ifdef __GLASGOW_HASKELL__- unsafeIndex _ _ = 0- unsafeRangeSize _ = 1-#endif--instance Bounded (Proxy s) where- minBound = Proxy- maxBound = Proxy--#ifdef MIN_VERSION_deepseq-instance NFData (Proxy s) where- rnf Proxy = ()-#endif--#ifdef MIN_VERSION_transformers-# if MIN_VERSION_transformers(0,4,0) && !(MIN_VERSION_transformers(0,5,0))-instance Eq1 Proxy where- eq1 = (==)--instance Ord1 Proxy where- compare1 = compare--instance Read1 Proxy where- readsPrec1 = readsPrec--instance Show1 Proxy where- showsPrec1 = showsPrec-# else-instance Eq1 Proxy where- liftEq _ _ _ = True--instance Ord1 Proxy where- liftCompare _ _ _ = EQ--instance Show1 Proxy where- liftShowsPrec _ _ _ _ = showString "Proxy"--instance Read1 Proxy where- liftReadsPrec _ _ _ =- readParen False (\r -> [(Proxy, s) | ("Proxy",s) <- lex r ])-# endif-#endif--instance Functor Proxy where- fmap _ _ = Proxy- {-# INLINE fmap #-}--instance Applicative Proxy where- pure _ = Proxy- {-# INLINE pure #-}- _ <*> _ = Proxy- {-# INLINE (<*>) #-}--instance Alternative Proxy where- empty = Proxy- {-# INLINE empty #-}- _ <|> _ = Proxy- {-# INLINE (<|>) #-}--instance Monoid (Proxy s) where- mempty = Proxy- {-# INLINE mempty #-}- mappend _ _ = Proxy- {-# INLINE mappend #-}- mconcat _ = Proxy- {-# INLINE mconcat #-}--instance Monad Proxy where- return _ = Proxy- {-# INLINE return #-}- _ >>= _ = Proxy- {-# INLINE (>>=) #-}--instance MonadPlus Proxy where- mzero = Proxy- {-# INLINE mzero #-}- mplus _ _ = Proxy- {-# INLINE mplus #-}--#if MIN_VERSION_base(4,4,0)-instance MonadZip Proxy where- mzipWith _ _ _ = Proxy- {-# INLINE mzipWith #-}-#endif--instance Foldable Proxy where- foldMap _ _ = mempty- {-# INLINE foldMap #-}- fold _ = mempty- {-# INLINE fold #-}- foldr _ z _ = z- {-# INLINE foldr #-}- foldl _ z _ = z- {-# INLINE foldl #-}- foldl1 _ _ = error "foldl1: Proxy"- {-# INLINE foldl1 #-}- foldr1 _ _ = error "foldr1: Proxy"- {-# INLINE foldr1 #-}--instance Traversable Proxy where- traverse _ _ = pure Proxy- {-# INLINE traverse #-}- sequenceA _ = pure Proxy- {-# INLINE sequenceA #-}- mapM _ _ = return Proxy- {-# INLINE mapM #-}- sequence _ = return Proxy- {-# INLINE sequence #-}---- | 'asProxyTypeOf' is a type-restricted version of 'const'.--- It is usually used as an infix operator, and its typing forces its first--- argument (which is usually overloaded) to have the same type as the tag--- of the second.-asProxyTypeOf :: a -> proxy a -> a-asProxyTypeOf = const-{-# INLINE asProxyTypeOf #-}---- | A concrete, promotable proxy type, for use at the kind level--- There are no instances for this because it is intended at the kind level only-data KProxy-#if __GLASGOW_HASKELL__ >= 706- (t :: *)-#else- t-#endif- = KProxy-#if defined(LANGUAGE_DeriveDataTypeable)- deriving Typeable-#endif
src/Data/Proxy/TH.hs view
@@ -1,44 +1,27 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE TemplateHaskellQuotes #-} #ifndef MIN_VERSION_template_haskell #define MIN_VERSION_template_haskell(x,y,z) 1 #endif -- template-haskell is only safe since GHC-8.2 #if __GLASGOW_HASKELL__ >= 802 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702+#else {-# LANGUAGE Trustworthy #-} #endif module Data.Proxy.TH ( pr-#if MIN_VERSION_template_haskell(2,8,0) , pr1-#endif ) where import Data.Char-#if __GLASGOW_HASKELL__ < 710-import Data.Functor-#endif-#if __GLASGOW_HASKELL__ < 707-import Data.Version (showVersion)-import Paths_tagged-#endif+import Data.Proxy (Proxy(..)) import Language.Haskell.TH import Language.Haskell.TH.Quote-import Language.Haskell.TH.Syntax proxy_d, proxy_tc :: Name-#if __GLASGOW_HASKELL__ >= 707-proxy_d = mkNameG_d "base" "Data.Proxy" "Proxy"-proxy_tc = mkNameG_tc "base" "Data.Proxy" "Proxy"-#else-proxy_d = mkNameG_d taggedPackageKey "Data.Proxy" "Proxy"-proxy_tc = mkNameG_tc taggedPackageKey "Data.Proxy" "Proxy"---- note: On 7.10+ this would use CURRENT_PACKAGE_KEY if we still housed the key.-taggedPackageKey :: String-taggedPackageKey = "tagged-" ++ showVersion version-#endif+proxy_d = 'Proxy+proxy_tc = ''Proxy proxyTypeQ :: TypeQ -> TypeQ proxyTypeQ t = appT (conT proxy_tc) t@@ -61,17 +44,12 @@ [h@(t:_)] | isUpper t -> p $ conT $ mkName h | otherwise -> p $ varT $ mkName h-#if MIN_VERSION_template_haskell(2,8,0) _ -> p $ mkList <$> cons-#endif where ts = map strip $ splitOn ',' s cons = mapM (conT . mkName) ts-#if MIN_VERSION_template_haskell(2,8,0) mkList = foldr (AppT . AppT PromotedConsT) PromotedNilT-#endif -#if MIN_VERSION_template_haskell(2,8,0) -- | Like 'pr', but takes a single type, which is used to produce a -- 'Proxy' for a single-element list containing only that type. This -- is useful for passing a single type to a function that wants a list@@ -86,7 +64,6 @@ | isUpper t -> p (fmap sing (conT $ mkName s)) | otherwise -> p (fmap sing (varT $ mkName s)) _ -> error "Empty string passed to pr1"-#endif -- | Split on a delimiter. splitOn :: Eq a => a -> [a] -> [[a]]
src/Data/Tagged.hs view
@@ -1,21 +1,9 @@ {-# LANGUAGE CPP #-}-#ifdef LANGUAGE_DeriveDataTypeable-{-# LANGUAGE DeriveDataTypeable #-}-#endif-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds #-}-#endif-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE DeriveGeneric #-}-#endif--- manual generics instances are not safe-#if __GLASGOW_HASKELL__ >= 707+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif -{-# OPTIONS_GHC -fno-warn-deprecations #-}+{-# OPTIONS_GHC -Wno-deprecations #-} ---------------------------------------------------------------------------- -- | -- Module : Data.Tagged@@ -46,12 +34,8 @@ , reproxy ) where -#if MIN_VERSION_base(4,8,0) && !(MIN_VERSION_base(4,18,0))+#if !(MIN_VERSION_base(4,18,0)) import Control.Applicative (liftA2)-#elif !(MIN_VERSION_base(4,8,0))-import Control.Applicative ((<$>), liftA2, Applicative(..))-import Data.Traversable (Traversable(..))-import Data.Monoid #endif import Data.Bits import Data.Foldable (Foldable(..))@@ -66,9 +50,7 @@ ) #endif import Control.Monad (liftM)-#if MIN_VERSION_base(4,8,0) import Data.Bifunctor-#endif #if MIN_VERSION_base(4,10,0) import Data.Bifoldable (Bifoldable(..)) import Data.Bitraversable (Bitraversable(..))@@ -81,21 +63,11 @@ import Data.Data #endif import Data.Ix (Ix(..))-#if __GLASGOW_HASKELL__ < 707-import Data.Proxy-#endif-#if MIN_VERSION_base(4,9,0) import Data.Semigroup (Semigroup(..))-#endif import Data.String (IsString(..)) import Foreign.Ptr (castPtr) import Foreign.Storable (Storable(..))-#if __GLASGOW_HASKELL__ >= 702-import GHC.Generics (Generic)-#if __GLASGOW_HASKELL__ >= 706-import GHC.Generics (Generic1)-#endif-#endif+import GHC.Generics (Generic, Generic1) -- | A @'Tagged' s b@ value is a value @b@ with an attached phantom type @s@. -- This can be used in place of the more traditional but less safe idiom of@@ -107,35 +79,10 @@ -- -- 'Tagged' has kind @k -> * -> *@ if the compiler supports @PolyKinds@, therefore -- there is an extra @k@ showing in the instance haddocks that may cause confusion.-newtype Tagged s b = Tagged { unTagged :: b } deriving- ( Eq, Ord, Ix, Bounded-#if __GLASGOW_HASKELL__ >= 702- , Generic-#if __GLASGOW_HASKELL__ >= 706- , Generic1-#endif-#endif--#if __GLASGOW_HASKELL__ >= 707- , Typeable-#endif-- )+newtype Tagged s b = Tagged { unTagged :: b }+ deriving (Eq, Ord, Ix, Bounded, Generic, Generic1) #ifdef __GLASGOW_HASKELL__-#if __GLASGOW_HASKELL__ < 707-instance Typeable2 Tagged where- typeOf2 _ = mkTyConApp taggedTyCon []--taggedTyCon :: TyCon-#if __GLASGOW_HASKELL__ < 704-taggedTyCon = mkTyCon "Data.Tagged.Tagged"-#else-taggedTyCon = mkTyCon3 "tagged" "Data.Tagged" "Tagged"-#endif--#endif- instance (Data s, Data b) => Data (Tagged s b) where gfoldl f z (Tagged b) = z Tagged `f` b toConstr _ = taggedConstr@@ -164,7 +111,6 @@ readsPrec d = readParen (d > 10) $ \r -> [(Tagged a, t) | ("Tagged", s) <- lex r, (a, t) <- readsPrec 11 s] -#if MIN_VERSION_base(4,9,0) instance Semigroup a => Semigroup (Tagged s a) where Tagged a <> Tagged b = Tagged (a <> b) stimes n (Tagged a) = Tagged (stimes n a)@@ -172,22 +118,15 @@ instance (Semigroup a, Monoid a) => Monoid (Tagged s a) where mempty = Tagged mempty mappend = (<>)-#else-instance Monoid a => Monoid (Tagged s a) where- mempty = Tagged mempty- mappend (Tagged a) (Tagged b) = Tagged (mappend a b)-#endif instance Functor (Tagged s) where fmap f (Tagged x) = Tagged (f x) {-# INLINE fmap #-} -#if MIN_VERSION_base(4,8,0) -- this instance is provided by the bifunctors package for GHC<7.9 instance Bifunctor Tagged where bimap _ g (Tagged b) = Tagged (g b) {-# INLINE bimap #-}-#endif #if MIN_VERSION_base(4,10,0) -- these instances are provided by the bifunctors package for GHC<8.1@@ -216,20 +155,7 @@ #endif #ifdef MIN_VERSION_transformers-# if MIN_VERSION_transformers(0,4,0) && !(MIN_VERSION_transformers(0,5,0)) instance Eq1 (Tagged s) where- eq1 = (==)--instance Ord1 (Tagged s) where- compare1 = compare--instance Read1 (Tagged s) where- readsPrec1 = readsPrec--instance Show1 (Tagged s) where- showsPrec1 = showsPrec-# else-instance Eq1 (Tagged s) where liftEq eq (Tagged a) (Tagged b) = eq a b instance Ord1 (Tagged s) where@@ -258,7 +184,6 @@ liftShowsPrec2 _ _ sp _ n (Tagged b) = showParen (n > 10) $ showString "Tagged " . sp 11 b-# endif #endif instance Applicative (Tagged s) where@@ -402,24 +327,16 @@ testBit (Tagged a) i = testBit a i isSigned (Tagged a) = isSigned a bitSize (Tagged a) = bitSize a -- deprecated, but still required :(-#if MIN_VERSION_base(4,5,0) unsafeShiftL (Tagged a) i = Tagged (unsafeShiftL a i) unsafeShiftR (Tagged a) i = Tagged (unsafeShiftR a i) popCount (Tagged a) = popCount a-#endif-#if MIN_VERSION_base(4,7,0) bitSizeMaybe (Tagged a) = bitSizeMaybe a zeroBits = Tagged zeroBits-#endif -#if MIN_VERSION_base(4,7,0) instance FiniteBits a => FiniteBits (Tagged s a) where finiteBitSize (Tagged a) = finiteBitSize a-# if MIN_VERSION_base(4,8,0) countLeadingZeros (Tagged a) = countLeadingZeros a countTrailingZeros (Tagged a) = countTrailingZeros a-# endif-#endif instance IsString a => IsString (Tagged s a) where fromString = Tagged . fromString
tagged.cabal view
@@ -1,5 +1,5 @@ name: tagged-version: 0.8.8+version: 0.8.9 license: BSD3 license-file: LICENSE author: Edward A. Kmett@@ -14,26 +14,24 @@ build-type: Simple cabal-version: >= 1.10 extra-source-files: .hlint.yaml CHANGELOG.markdown README.markdown-tested-with: GHC == 7.0.4- , GHC == 7.2.2- , GHC == 7.4.2- , GHC == 7.6.3- , GHC == 7.8.4- , GHC == 7.10.3- , GHC == 8.0.2- , GHC == 8.2.2- , GHC == 8.4.4- , GHC == 8.6.5- , GHC == 8.8.4- , GHC == 8.10.7- , GHC == 9.0.2- , GHC == 9.2.8- , GHC == 9.4.5- , GHC == 9.6.2+tested-with:+ GHC == 8.0.2+ GHC == 8.2.2+ GHC == 8.4.4+ GHC == 8.6.5+ GHC == 8.8.4+ GHC == 8.10.7+ GHC == 9.0.2+ GHC == 9.2.8+ GHC == 9.4.8+ GHC == 9.6.6+ GHC == 9.8.4+ GHC == 9.10.1+ GHC == 9.12.1 source-repository head type: git- location: git://github.com/ekmett/tagged.git+ location: https://github.com/ekmett/tagged.git flag deepseq description:@@ -54,40 +52,22 @@ library default-language: Haskell98 other-extensions: CPP- build-depends: base >= 2 && < 5+ build-depends:+ base >= 4.9 && < 5,+ template-haskell >= 2.11 && < 2.24 ghc-options: -Wall hs-source-dirs: src- exposed-modules: Data.Tagged+ exposed-modules:+ Data.Proxy.TH+ Data.Tagged 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(hugs)- cpp-options: -DLANGUAGE_DeriveDataTypeable- other-extensions: DeriveDataTypeable-- if impl(ghc<7.7)- hs-source-dirs: old- exposed-modules: Data.Proxy- other-modules: Paths_tagged-- if impl(ghc>=7.2 && <7.5)- build-depends: ghc-prim-- if impl(ghc>=7.6)- exposed-modules: Data.Proxy.TH- build-depends: template-haskell >= 2.8 && < 2.22- if flag(deepseq) build-depends: deepseq >= 1.1 && < 1.6 if flag(transformers)- build-depends: transformers >= 0.2 && < 0.7-- -- Ensure Data.Functor.Classes is always available- if impl(ghc >= 7.10) || impl(ghcjs)- build-depends: transformers >= 0.4.2.0- else- build-depends: transformers-compat >= 0.5 && < 1+ build-depends: transformers >= 0.4.2.0 && < 0.7