Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) The University of Glasgow CWI 2001--2017
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilitynon-portable (requires GADTs and compiler support)
Safe HaskellTrustworthy
LanguageHaskell2010

Type.Reflection

Contents

Description

This provides a type-indexed type representation mechanism, similar to that described by,

  • Simon Peyton-Jones, Stephanie Weirich, Richard Eisenberg, Dimitrios Vytiniotis. "A reflection on types." /Proc. Philip Wadler's 60th birthday Festschrift/, Edinburgh (April 2016).

The interface providesTypeRep, a type representation which can be safely decomposed and composed. SeeData.Dynamic for an example of this.

Since: 4.10.0.0

Synopsis

The Typeable class

classTypeable (a :: k)Source#

The classTypeable allows a concrete representation of a type to be calculated.

Minimal complete definition

typeRep#

typeRep ::Typeable a =>TypeRep aSource#

withTypeable ::forall k (a :: k) rep (r ::TYPE rep).TypeRep a -> (Typeable a => r) -> rSource#

Use aTypeRep asTypeable evidence.

Propositional equality

data a:~: bwhereinfix 4Source#

Propositional equality. Ifa :~: b is inhabited by some terminating value, then the typea is the same as the typeb. To use this equality in practice, pattern-match on thea :~: b to get out theRefl constructor; in the body of the pattern-match, the compiler knows thata ~ b.

Since: 4.7.0.0

Constructors

Refl :: a:~: a 
Instances
Category ((:~:) :: k -> k ->Type)Source#

Since: 4.7.0.0

Instance details

Defined inControl.Category

Methods

id :: a:~: aSource#

(.) :: (b:~: c) -> (a:~: b) -> a:~: cSource#

TestEquality ((:~:) a :: k ->Type)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Equality

Methods

testEquality :: (a:~: a0) -> (a:~: b) ->Maybe (a0:~: b)Source#

TestCoercion ((:~:) a :: k ->Type)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Coercion

Methods

testCoercion :: (a:~: a0) -> (a:~: b) ->Maybe (Coercion a0 b)Source#

a ~ b =>Bounded (a:~: b)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Equality

a ~ b =>Enum (a:~: b)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Equality

Methods

succ :: (a:~: b) -> a:~: bSource#

pred :: (a:~: b) -> a:~: bSource#

toEnum ::Int -> a:~: bSource#

fromEnum :: (a:~: b) ->IntSource#

enumFrom :: (a:~: b) -> [a:~: b]Source#

enumFromThen :: (a:~: b) -> (a:~: b) -> [a:~: b]Source#

enumFromTo :: (a:~: b) -> (a:~: b) -> [a:~: b]Source#

enumFromThenTo :: (a:~: b) -> (a:~: b) -> (a:~: b) -> [a:~: b]Source#

Eq (a:~: b)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Equality

Methods

(==) :: (a:~: b) -> (a:~: b) ->Bool#

(/=) :: (a:~: b) -> (a:~: b) ->Bool#

(a ~ b,Data a) =>Data (a:~: b)Source#

Since: 4.7.0.0

Instance details

Defined inData.Data

Methods

gfoldl :: (forall d b0.Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> (a:~: b) -> c (a:~: b)Source#

gunfold :: (forall b0 r.Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) ->Constr -> c (a:~: b)Source#

toConstr :: (a:~: b) ->ConstrSource#

dataTypeOf :: (a:~: b) ->DataTypeSource#

dataCast1 ::Typeable t => (forall d.Data d => c (t d)) ->Maybe (c (a:~: b))Source#

dataCast2 ::Typeable t => (forall d e. (Data d,Data e) => c (t d e)) ->Maybe (c (a:~: b))Source#

gmapT :: (forall b0.Data b0 => b0 -> b0) -> (a:~: b) -> a:~: bSource#

gmapQl :: (r -> r' -> r) -> r -> (forall d.Data d => d -> r') -> (a:~: b) -> rSource#

gmapQr :: (r' -> r -> r) -> r -> (forall d.Data d => d -> r') -> (a:~: b) -> rSource#

gmapQ :: (forall d.Data d => d -> u) -> (a:~: b) -> [u]Source#

gmapQi ::Int -> (forall d.Data d => d -> u) -> (a:~: b) -> uSource#

gmapM ::Monad m => (forall d.Data d => d -> m d) -> (a:~: b) -> m (a:~: b)Source#

gmapMp ::MonadPlus m => (forall d.Data d => d -> m d) -> (a:~: b) -> m (a:~: b)Source#

gmapMo ::MonadPlus m => (forall d.Data d => d -> m d) -> (a:~: b) -> m (a:~: b)Source#

Ord (a:~: b)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Equality

Methods

compare :: (a:~: b) -> (a:~: b) ->Ordering#

(<) :: (a:~: b) -> (a:~: b) ->Bool#

(<=) :: (a:~: b) -> (a:~: b) ->Bool#

(>) :: (a:~: b) -> (a:~: b) ->Bool#

(>=) :: (a:~: b) -> (a:~: b) ->Bool#

max :: (a:~: b) -> (a:~: b) -> a:~: b#

min :: (a:~: b) -> (a:~: b) -> a:~: b#

a ~ b =>Read (a:~: b)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Equality

Show (a:~: b)Source#

Since: 4.7.0.0

Instance details

Defined inData.Type.Equality

data (a :: k1):~~: (b :: k2)whereinfix 4Source#

Kind heterogeneous propositional equality. Like:~:,a :~~: b is inhabited by a terminating value if and only ifa is the same type asb.

Since: 4.10.0.0

Constructors

HRefl :: a:~~: a 
Instances
Category ((:~~:) :: k -> k ->Type)Source#

Since: 4.10.0.0

Instance details

Defined inControl.Category

Methods

id :: a:~~: aSource#

(.) :: (b:~~: c) -> (a:~~: b) -> a:~~: cSource#

TestEquality ((:~~:) a :: k ->Type)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Equality

Methods

testEquality :: (a:~~: a0) -> (a:~~: b) ->Maybe (a0:~: b)Source#

TestCoercion ((:~~:) a :: k ->Type)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Coercion

Methods

testCoercion :: (a:~~: a0) -> (a:~~: b) ->Maybe (Coercion a0 b)Source#

a~~ b =>Bounded (a:~~: b)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Equality

a~~ b =>Enum (a:~~: b)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Equality

Methods

succ :: (a:~~: b) -> a:~~: bSource#

pred :: (a:~~: b) -> a:~~: bSource#

toEnum ::Int -> a:~~: bSource#

fromEnum :: (a:~~: b) ->IntSource#

enumFrom :: (a:~~: b) -> [a:~~: b]Source#

enumFromThen :: (a:~~: b) -> (a:~~: b) -> [a:~~: b]Source#

enumFromTo :: (a:~~: b) -> (a:~~: b) -> [a:~~: b]Source#

enumFromThenTo :: (a:~~: b) -> (a:~~: b) -> (a:~~: b) -> [a:~~: b]Source#

Eq (a:~~: b)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Equality

Methods

(==) :: (a:~~: b) -> (a:~~: b) ->Bool#

(/=) :: (a:~~: b) -> (a:~~: b) ->Bool#

(Typeable i,Typeable j,Typeable a,Typeable b, a~~ b) =>Data (a:~~: b)Source#

Since: 4.10.0.0

Instance details

Defined inData.Data

Methods

gfoldl :: (forall d b0.Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> (a:~~: b) -> c (a:~~: b)Source#

gunfold :: (forall b0 r.Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) ->Constr -> c (a:~~: b)Source#

toConstr :: (a:~~: b) ->ConstrSource#

dataTypeOf :: (a:~~: b) ->DataTypeSource#

dataCast1 ::Typeable t => (forall d.Data d => c (t d)) ->Maybe (c (a:~~: b))Source#

dataCast2 ::Typeable t => (forall d e. (Data d,Data e) => c (t d e)) ->Maybe (c (a:~~: b))Source#

gmapT :: (forall b0.Data b0 => b0 -> b0) -> (a:~~: b) -> a:~~: bSource#

gmapQl :: (r -> r' -> r) -> r -> (forall d.Data d => d -> r') -> (a:~~: b) -> rSource#

gmapQr :: (r' -> r -> r) -> r -> (forall d.Data d => d -> r') -> (a:~~: b) -> rSource#

gmapQ :: (forall d.Data d => d -> u) -> (a:~~: b) -> [u]Source#

gmapQi ::Int -> (forall d.Data d => d -> u) -> (a:~~: b) -> uSource#

gmapM ::Monad m => (forall d.Data d => d -> m d) -> (a:~~: b) -> m (a:~~: b)Source#

gmapMp ::MonadPlus m => (forall d.Data d => d -> m d) -> (a:~~: b) -> m (a:~~: b)Source#

gmapMo ::MonadPlus m => (forall d.Data d => d -> m d) -> (a:~~: b) -> m (a:~~: b)Source#

Ord (a:~~: b)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Equality

Methods

compare :: (a:~~: b) -> (a:~~: b) ->Ordering#

(<) :: (a:~~: b) -> (a:~~: b) ->Bool#

(<=) :: (a:~~: b) -> (a:~~: b) ->Bool#

(>) :: (a:~~: b) -> (a:~~: b) ->Bool#

(>=) :: (a:~~: b) -> (a:~~: b) ->Bool#

max :: (a:~~: b) -> (a:~~: b) -> a:~~: b#

min :: (a:~~: b) -> (a:~~: b) -> a:~~: b#

a~~ b =>Read (a:~~: b)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Equality

Show (a:~~: b)Source#

Since: 4.10.0.0

Instance details

Defined inData.Type.Equality

Type representations

Type-Indexed

dataTypeRep (a :: k)Source#

A concrete representation of a (monomorphic) type.TypeRep supports reasonably efficient equality.

Instances
TestEquality (TypeRep :: k ->Type)Source# 
Instance details

Defined inData.Typeable.Internal

Eq (TypeRep a)Source#

Since: 2.1

Instance details

Defined inData.Typeable.Internal

Methods

(==) ::TypeRep a ->TypeRep a ->Bool#

(/=) ::TypeRep a ->TypeRep a ->Bool#

Ord (TypeRep a)Source#

Since: 4.4.0.0

Instance details

Defined inData.Typeable.Internal

Show (TypeRep a)Source# 
Instance details

Defined inData.Typeable.Internal

typeOf ::Typeable a => a ->TypeRep aSource#

patternApp ::forall k2 (t :: k2). () =>forall k1 (a :: k1 -> k2) (b :: k1). t ~ a b =>TypeRep a ->TypeRep b ->TypeRep tSource#

A type application.

For instance,

typeRep @(Maybe Int) === App (typeRep @Maybe) (typeRep @Int)

Note that this will also match a function type,

typeRep @(Int# -> Char)  ===App (App arrow (typeRep @Int#)) (typeRep @Char)

wherearrow :: TypeRep ((->) :: TYPE IntRep -> Type -> Type).

patternCon ::forall k (a :: k). () => IsApplication a ~ "" =>TyCon ->TypeRep aSource#

Pattern match on a type constructor

patternCon' ::forall k (a :: k). () => IsApplication a ~ "" =>TyCon -> [SomeTypeRep] ->TypeRep aSource#

Pattern match on a type constructor including its instantiated kind variables.

For instance,

App (Con' proxyTyCon ks) intRep = typeRep @(Proxy @Int)

will bring into scope,

proxyTyCon :: TyConks         == [someTypeRepType] :: [SomeTypeRep]intRep     == typeRepInt

patternFun ::forall k (fun :: k). () =>forall (r1 ::RuntimeRep) (r2 ::RuntimeRep) (arg ::TYPE r1) (res ::TYPE r2). (k ~Type, fun~~ (arg -> res)) =>TypeRep arg ->TypeRep res ->TypeRep funSource#

The function type constructor.

For instance,

typeRep @(Int -> Char) === Fun (typeRep @Int) (typeRep @Char)

typeRepTyCon ::TypeRep a ->TyConSource#

Observe the type constructor of a type representation

rnfTypeRep ::TypeRep a -> ()Source#

Helper to fully evaluateTypeRep for use asNFData(rnf) implementation

Since: 4.8.0.0

eqTypeRep ::forall k1 k2 (a :: k1) (b :: k2).TypeRep a ->TypeRep b ->Maybe (a:~~: b)Source#

Type equality

Since: 4.10

typeRepKind ::TypeRep (a :: k) ->TypeRep kSource#

Observe the kind of a type.

splitApps ::TypeRep a -> (TyCon, [SomeTypeRep])Source#

Quantified

dataSomeTypeRepwhereSource#

A non-indexed type representation.

Constructors

SomeTypeRep ::forall k (a :: k). !(TypeRep a) ->SomeTypeRep 
Instances
EqSomeTypeRepSource# 
Instance details

Defined inData.Typeable.Internal

OrdSomeTypeRepSource# 
Instance details

Defined inData.Typeable.Internal

ShowSomeTypeRepSource#

Since: 4.10.0.0

Instance details

Defined inData.Typeable.Internal

someTypeRep ::forall proxy a.Typeable a => proxy a ->SomeTypeRepSource#

Takes a value of typea and returns a concrete representation of that type.

Since: 4.7.0.0

someTypeRepTyCon ::SomeTypeRep ->TyConSource#

Observe the type constructor of a quantified type representation.

rnfSomeTypeRep ::SomeTypeRep -> ()Source#

Helper to fully evaluateSomeTypeRep for use asNFData(rnf) implementation

Since: 4.10.0.0

Type constructors

dataTyCon#

Instances
EqTyCon 
Instance details

Defined inGHC.Classes

OrdTyCon 
Instance details

Defined inGHC.Classes

ShowTyConSource#

Since: 2.1

Instance details

Defined inGHC.Show

tyConPackage ::TyCon ->StringSource#

tyConModule ::TyCon ->StringSource#

tyConName ::TyCon ->StringSource#

rnfTyCon ::TyCon -> ()Source#

Module names

dataModule#

Instances
EqModule 
Instance details

Defined inGHC.Classes

ShowModuleSource#

Since: 4.9.0.0

Instance details

Defined inGHC.Show

moduleName ::Module ->StringSource#

modulePackage ::Module ->StringSource#

rnfModule ::Module -> ()Source#

Helper to fully evaluateTyCon for use asNFData(rnf) implementation

Since: 4.8.0.0

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp