{-# LANGUAGE Trustworthy #-}{-# LANGUAGE NoImplicitPrelude #-}{-# LANGUAGE PolyKinds #-}------------------------------------------------------------------------------- |-- Module : Data.Proxy-- License : BSD-style (see the LICENSE file in the distribution)---- Maintainer : libraries@haskell.org-- Stability : experimental-- Portability : portable---- Definition of a Proxy type (poly-kinded in GHC)---- @since 4.7.0.0-----------------------------------------------------------------------------moduleData.Proxy(Proxy (..),asProxyTypeOf ,KProxy (..))whereimportGHC.Base importGHC.Show importGHC.Read importGHC.Enum importGHC.Arr -- | A concrete, poly-kinded proxy typedataProxy t =Proxy -- | 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 onlydataKProxy (t ::*)=KProxy -- It's common to use (undefined :: Proxy t) and (Proxy :: Proxy t)-- interchangeably, so all of these instances are hand-written to be-- lazy in Proxy arguments.instanceEq(Proxy s )where_== _=TrueinstanceOrd(Proxy s )wherecompare __=EQinstanceShow (Proxy s )whereshowsPrec __=showString "Proxy"instanceRead (Proxy s )wherereadsPrec d =readParen (d >10)(\r ->[(Proxy ,s )|("Proxy",s )<-lex r ])instanceEnum (Proxy s )wheresucc _=errorWithoutStackTrace "Proxy.succ"pred _=errorWithoutStackTrace "Proxy.pred"fromEnum _=0toEnum 0=Proxy toEnum_=errorWithoutStackTrace "Proxy.toEnum: 0 expected"enumFrom _=[Proxy ]enumFromThen __=[Proxy ]enumFromThenTo ___=[Proxy ]enumFromTo __=[Proxy ]instanceIx (Proxy s )whererange _=[Proxy ]index __=0inRange __=TruerangeSize _=1unsafeIndex __=0unsafeRangeSize _=1instanceBounded (Proxy s )whereminBound =Proxy maxBound =Proxy instanceMonoid (Proxy s )wheremempty =Proxy mappend __=Proxy mconcat _=Proxy instanceFunctor Proxy wherefmap __=Proxy {-# INLINE fmap #-}instanceApplicative Proxy wherepure _=Proxy {-# INLINE pure #-}_<*> _=Proxy {-# INLINE (<*>) #-}instanceAlternative Proxy whereempty =Proxy {-# INLINE empty #-}_<|> _=Proxy {-# INLINE (<|>) #-}instanceMonad Proxy where_>>= _=Proxy {-# INLINE (>>=) #-}instanceMonadPlus Proxy -- | '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 #-}

AltStyle によって変換されたページ (->オリジナル) /