Movatterモバイル変換


[0]ホーム

URL:


{-# 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.BaseimportGHC.ShowimportGHC.ReadimportGHC.EnumimportGHC.Arr-- $setup-- >>> import Data.Void-- >>> import Prelude-- | 'Proxy' is a type that holds no data, but has a phantom parameter of-- arbitrary type (or even kind). Its use is to provide type information, even-- though there is no value available of that type (or it may be too costly to-- create one).---- Historically, @'Proxy' :: 'Proxy' a@ is a safer alternative to the-- @'undefined :: a'@ idiom.---- >>> Proxy :: Proxy (Void, Int -> Int)-- Proxy---- Proxy can even hold types of higher kinds,---- >>> Proxy :: Proxy Either-- Proxy---- >>> Proxy :: Proxy Functor-- Proxy---- >>> Proxy :: Proxy complicatedStructure-- ProxydataProxyt=Proxyderiving(Bounded-- ^ @since 4.7.0.0,Read-- ^ @since 4.7.0.0)-- | 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::Type)=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.-- | @since 4.7.0.0instanceEq(Proxys)where_==_=True-- | @since 4.7.0.0instanceOrd(Proxys)wherecompare__=EQ-- | @since 4.7.0.0instanceShow(Proxys)whereshowsPrec__=showString"Proxy"-- | @since 4.7.0.0instanceEnum(Proxys)wheresucc_=errorWithoutStackTrace"Proxy.succ"pred_=errorWithoutStackTrace"Proxy.pred"fromEnum_=0toEnum0=ProxytoEnum_=errorWithoutStackTrace"Proxy.toEnum: 0 expected"enumFrom_=[Proxy]enumFromThen__=[Proxy]enumFromThenTo___=[Proxy]enumFromTo__=[Proxy]-- | @since 4.7.0.0instanceIx(Proxys)whererange_=[Proxy]index__=0inRange__=TruerangeSize_=1unsafeIndex__=0unsafeRangeSize_=1-- | @since 4.9.0.0instanceSemigroup(Proxys)where_<>_=Proxysconcat_=Proxystimes__=Proxy-- | @since 4.7.0.0instanceMonoid(Proxys)wheremempty=Proxymconcat_=Proxy-- | @since 4.7.0.0instanceFunctorProxywherefmap__=Proxy{-# INLINEfmap#-}-- | @since 4.7.0.0instanceApplicativeProxywherepure_=Proxy{-# INLINEpure#-}_<*>_=Proxy{-# INLINE(<*>)#-}-- | @since 4.9.0.0instanceAlternativeProxywhereempty=Proxy{-# INLINEempty#-}_<|>_=Proxy{-# INLINE(<|>)#-}-- | @since 4.7.0.0instanceMonadProxywhere_>>=_=Proxy{-# INLINE(>>=)#-}-- | @since 4.9.0.0instanceMonadPlusProxy-- | '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.---- >>> import Data.Word-- >>> :type asProxyTypeOf 123 (Proxy :: Proxy Word8)-- asProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8---- Note the lower-case @proxy@ in the definition. This allows any type-- constructor with just one argument to be passed to the function, for example-- we could also write---- >>> import Data.Word-- >>> :type asProxyTypeOf 123 (Just (undefined :: Word8))-- asProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8asProxyTypeOf::a->proxya->aasProxyTypeOf=const{-# INLINEasProxyTypeOf#-}

[8]ページ先頭

©2009-2025 Movatter.jp