#ifdef LANGUAGE_DeriveDataTypeable
#endif
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706
#endif
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 707
#endif
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702
#endif
module Data.Proxy
(
Proxy(..)
, reproxy
, asProxyTypeOf
) where
import Control.Applicative (Applicative(..))
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
#endif
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 707
deriving instance Typeable Proxy
#else
data Proxy s = Proxy
#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 d = readParen (d > 10) (\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
#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
proxyDataType :: DataType
proxyDataType = mkDataType "Data.Proxy.Proxy" [proxyConstr]
#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
instance Functor Proxy where
fmap _ _ = Proxy
instance Applicative Proxy where
pure _ = Proxy
_ <*> _ = Proxy
instance Monoid (Proxy s) where
mempty = Proxy
mappend _ _ = Proxy
mconcat _ = Proxy
instance Monad Proxy where
return _ = Proxy
_ >>= _ = Proxy
instance Foldable Proxy where
foldMap _ _ = mempty
fold _ = mempty
foldr _ z _ = z
foldl _ z _ = z
foldl1 _ _ = error "foldl1: Proxy"
foldr1 _ _ = error "foldr1: Proxy"
instance Traversable Proxy where
traverse _ _ = pure Proxy
sequenceA _ = pure Proxy
mapM _ _ = return Proxy
sequence _ = return Proxy
reproxy :: proxy s -> Proxy t
reproxy _ = Proxy
asProxyTypeOf :: a -> proxy a -> a
asProxyTypeOf = const