tagged 0.4.2.1 → 0.4.3
raw patch · 3 files changed
+26/−20 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Proxy.hs +15/−12
- Data/Tagged.hs +10/−7
- tagged.cabal +1/−1
Data/Proxy.hs view
@@ -2,6 +2,9 @@ #ifdef LANGUAGE_DeriveDataTypeable {-# LANGUAGE DeriveDataTypeable #-} #endif+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ > 706+{-# LANGUAGE PolyKinds #-}+#endif ---------------------------------------------------------------------------- -- | -- Module : Data.Proxy@@ -15,7 +18,7 @@ ------------------------------------------------------------------------------- module Data.Proxy- ( + ( -- * Tagged values Proxy(..) , reproxy@@ -38,7 +41,7 @@ import GHC.Arr (unsafeIndex, unsafeRangeSize) #endif -data Proxy p = Proxy deriving +data Proxy p = Proxy deriving ( Eq, Ord, Show, Read #ifdef LANGUAGE_DeriveDataTypeable , Data, Typeable@@ -56,7 +59,7 @@ enumFromThenTo _ _ _ = [Proxy] enumFromTo _ _ = [Proxy] -{- +{- Work around for the following GHC bug with deriving Ix instances with a phantom type: Data/Tagged.hs:1:0:@@ -78,11 +81,11 @@ unsafeIndex _ _ = 0 unsafeRangeSize _ = 1 #endif- + instance Bounded (Proxy s) where minBound = Proxy maxBound = Proxy- + instance Functor Proxy where fmap _ _ = Proxy {-# INLINE fmap #-}@@ -132,8 +135,8 @@ {-# INLINE sequence #-} -- | Some times you need to change the proxy you have lying around.--- Idiomatic usage is to make a new combinator for the relationship --- between the proxies that you want to enforce, and define that +-- Idiomatic usage is to make a new combinator for the relationship+-- between the proxies that you want to enforce, and define that -- combinator using 'reproxy'. -- -- > data Succ n@@ -143,21 +146,21 @@ reproxy _ = Proxy {-# INLINE reproxy #-} --- | Convert from a 'Tagged' representation to a representation +-- | Convert from a 'Tagged' representation to a representation -- based on a 'Proxy'. proxy :: Tagged s a -> Proxy s -> a proxy (Tagged x) _ = x {-# INLINE proxy #-} --- | Convert from a representation based on a 'Proxy' to a 'Tagged' +-- | Convert from a representation based on a 'Proxy' to a 'Tagged' -- representation. unproxy :: (Proxy s -> a) -> Tagged s a unproxy f = Tagged (f Proxy) {-# INLINE unproxy #-} --- | '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 +-- | '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
Data/Tagged.hs view
@@ -2,6 +2,9 @@ #ifdef LANGUAGE_DeriveDataTypeable {-# LANGUAGE DeriveDataTypeable #-} #endif+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ > 706+{-# LANGUAGE PolyKinds #-}+#endif ---------------------------------------------------------------------------- -- | -- Module : Data.Tagged@@ -15,7 +18,7 @@ ------------------------------------------------------------------------------- module Data.Tagged- ( + ( -- * Tagged values Tagged(..) , retag@@ -37,13 +40,13 @@ -- | 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--- passing in an undefined value with the type, because unlike an @(s -> b)@, +-- passing in an undefined value with the type, because unlike an @(s -> b)@, -- a @'Tagged' s b@ can't try to use the argument @s@ as a real value. -- -- Moreover, you don't have to rely on the compiler to inline away the extra -- argument, because the newtype is \"free\" -newtype Tagged s b = Tagged { unTagged :: b } deriving +newtype Tagged s b = Tagged { unTagged :: b } deriving ( Eq, Ord, Ix, Bounded #ifdef LANGUAGE_DeriveDataTypeable , Data, Typeable@@ -63,7 +66,7 @@ mempty = Tagged mempty mappend (Tagged a) (Tagged b) = Tagged (mappend a b) -instance Functor (Tagged s) where +instance Functor (Tagged s) where fmap f (Tagged x) = Tagged (f x) {-# INLINE fmap #-} @@ -76,7 +79,7 @@ instance Monad (Tagged s) where return = Tagged {-# INLINE return #-}- Tagged m >>= k = k m + Tagged m >>= k = k m {-# INLINE (>>=) #-} _ >> n = n {-# INLINE (>>) #-}@@ -90,7 +93,7 @@ {-# INLINE foldr #-} foldl f z (Tagged x) = f z x {-# INLINE foldl #-}- foldl1 _ (Tagged x) = x + foldl1 _ (Tagged x) = x {-# INLINE foldl1 #-} foldr1 _ (Tagged x) = x {-# INLINE foldr1 #-}@@ -196,7 +199,7 @@ -- > retagSucc :: Tagged n a -> Tagged (Succ n) a -- > retagSucc = retag retag :: Tagged s b -> Tagged t b-retag = Tagged . unTagged +retag = Tagged . unTagged {-# INLINE retag #-} -- | Alias for 'unTagged'
tagged.cabal view
@@ -1,5 +1,5 @@ name: tagged-version: 0.4.2.1+version: 0.4.3 license: BSD3 license-file: LICENSE author: Edward A. Kmett