tagged 0.4.1 → 0.4.2
raw patch · 3 files changed
+32/−19 lines, 3 files
Files
- Data/Proxy.hs +6/−3
- Data/Tagged.hs +17/−10
- tagged.cabal +9/−6
Data/Proxy.hs view
@@ -1,4 +1,7 @@-{-# LANGUAGE CPP, GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP #-}+#ifdef LANGUAGE_DeriveDataTypeable+{-# LANGUAGE DeriveDataTypeable #-}+#endif ---------------------------------------------------------------------------- -- | -- Module : Data.Proxy@@ -7,7 +10,7 @@ -- -- Maintainer : Edward Kmett <ekmett@gmail.com> -- Stability : experimental--- Portability : generalized newtype deriving+-- Portability : portable -- ------------------------------------------------------------------------------- @@ -38,7 +41,7 @@ data Proxy p = Proxy deriving ( Eq, Ord, Show, Read #ifdef LANGUAGE_DeriveDataTypeable- , Data,Typeable+ , Data, Typeable #endif )
Data/Tagged.hs view
@@ -1,4 +1,7 @@ {-# LANGUAGE CPP #-}+#ifdef LANGUAGE_DeriveDataTypeable+{-# LANGUAGE DeriveDataTypeable #-}+#endif ---------------------------------------------------------------------------- -- | -- Module : Data.Tagged@@ -7,7 +10,7 @@ -- -- Maintainer : Edward Kmett <ekmett@gmail.com> -- Stability : experimental--- Portability : generalized newtype deriving+-- Portability : portable -- ------------------------------------------------------------------------------- @@ -30,6 +33,7 @@ import Data.Data (Data,Typeable) #endif import Data.Ix (Ix(..))+import Data.Monoid -- | 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@@ -55,6 +59,10 @@ readsPrec d = readParen (d > 10) $ \r -> [(Tagged a, t) | ("Tagged", s) <- lex r, (a, t) <- readsPrec 11 s] +instance Monoid a => Monoid (Tagged s a) where+ mempty = Tagged mempty+ mappend (Tagged a) (Tagged b) = Tagged (mappend a b)+ instance Functor (Tagged s) where fmap f (Tagged x) = Tagged (f x) {-# INLINE fmap #-}@@ -97,7 +105,7 @@ sequence (Tagged x) = liftM Tagged x {-# INLINE sequence #-} -instance (Enum a) => Enum (Tagged s a) where+instance Enum a => Enum (Tagged s a) where succ = fmap succ pred = fmap pred toEnum = Tagged . toEnum@@ -108,7 +116,7 @@ enumFromThenTo (Tagged x) (Tagged y) (Tagged z) = map Tagged (enumFromThenTo x y z) -instance (Num a) => Num (Tagged s a) where+instance Num a => Num (Tagged s a) where (+) = liftA2 (+) (-) = liftA2 (-) (*) = liftA2 (*)@@ -117,10 +125,10 @@ signum = fmap signum fromInteger = Tagged . fromInteger -instance (Real a) => Real (Tagged s a) where+instance Real a => Real (Tagged s a) where toRational (Tagged x) = toRational x -instance (Integral a) => Integral (Tagged s a) where+instance Integral a => Integral (Tagged s a) where quot = liftA2 quot rem = liftA2 rem div = liftA2 div@@ -131,12 +139,12 @@ (a, b) = divMod x y toInteger (Tagged x) = toInteger x -instance (Fractional a) => Fractional (Tagged s a) where+instance Fractional a => Fractional (Tagged s a) where (/) = liftA2 (/) recip = fmap recip fromRational = Tagged . fromRational -instance (Floating a) => Floating (Tagged s a) where+instance Floating a => Floating (Tagged s a) where pi = Tagged pi exp = fmap exp log = fmap log@@ -156,7 +164,7 @@ (**) = liftA2 (**) logBase = liftA2 (**) -instance (RealFrac a) => RealFrac (Tagged s a) where+instance RealFrac a => RealFrac (Tagged s a) where properFraction (Tagged x) = (a, Tagged b) where (a, b) = properFraction x truncate (Tagged x) = truncate x@@ -164,7 +172,7 @@ ceiling (Tagged x) = ceiling x floor (Tagged x) = floor x -instance (RealFloat a) => RealFloat (Tagged s a) where+instance RealFloat a => RealFloat (Tagged s a) where floatRadix (Tagged x) = floatRadix x floatDigits (Tagged x) = floatDigits x floatRange (Tagged x) = floatRange x@@ -209,4 +217,3 @@ untagSelf :: Tagged a a -> a untagSelf (Tagged x) = x {-# INLINE untagSelf #-}-
tagged.cabal view
@@ -1,27 +1,30 @@ name: tagged-version: 0.4.1+version: 0.4.2 license: BSD3 license-file: LICENSE author: Edward A. Kmett maintainer: Edward A. Kmett <ekmett@gmail.com> stability: experimental category: Data, Phantom Types-synopsis: Provides newtype wrappers for phantom types to avoid unsafely passing dummy arguments+synopsis: Haskell 98 phantom types to avoid unsafely passing dummy arguments homepage: http://github.com/ekmett/tagged copyright: 2009-2011 Edward A. Kmett-description: Provides newtype wrappers for phantom types to avoid unsafely passing dummy arguments+description: Haskell 98 phantom types to avoid unsafely passing dummy arguments build-type: Simple-cabal-version: >=1.6+cabal-version: >= 1.10 source-repository head type: git location: git://github.com/ekmett/tagged.git library+ default-language: Haskell98+ other-extensions: CPP if !impl(hugs) cpp-options: -DLANGUAGE_DeriveDataTypeable- extensions: DeriveDataTypeable- build-depends: base >= 2 && < 5+ other-extensions: DeriveDataTypeable+ build-depends:+ base >= 2 && < 5 exposed-modules: Data.Tagged Data.Proxy