#ifdef LANGUAGE_DeriveDataTypeable
#endif
#if __GLASGOW_HASKELL__ >= 706
#endif
#if __GLASGOW_HASKELL__ >= 707
#endif
#if __GLASGOW_HASKELL__ >= 702
#endif
module Data.Proxy
(
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
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
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 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
#ifdef MIN_VERSION_deepseq
instance NFData (Proxy s) where
rnf Proxy = ()
#endif
instance Functor Proxy where
fmap _ _ = Proxy
instance Applicative Proxy where
pure _ = Proxy
_ <*> _ = Proxy
instance Alternative Proxy where
empty = Proxy
_ <|> _ = Proxy
instance Monoid (Proxy s) where
mempty = Proxy
mappend _ _ = Proxy
mconcat _ = Proxy
instance Monad Proxy where
return _ = Proxy
_ >>= _ = Proxy
instance MonadPlus Proxy where
mzero = Proxy
mplus _ _ = Proxy
#if MIN_VERSION_base(4,4,0)
instance MonadZip Proxy where
mzipWith _ _ _ = Proxy
#endif
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
asProxyTypeOf :: a -> proxy a -> a
asProxyTypeOf = const
data KProxy
#if __GLASGOW_HASKELL__ >= 706
(t :: *)
#else
t
#endif
= KProxy
#if defined(LANGUAGE_DeriveDataTypeable)
deriving Typeable
#endif