Type.Reflection.Compat

base-compat-0.14.1: A compatibility layer for base

Safe Haskell | Trustworthy
Language | Haskell2010

Type.Reflection.Compat

Synopsis

- module Type.Reflection
- withTypeable :: forall k (a :: k) r. TypeRep a -> (Typeable a => r) -> r
- pattern TypeRep :: () => Typeable a => TypeRep a
- decTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> Either ((a :~~: b) -> Void) (a :~~: b)

# Documentation

module Type.Reflection

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

Use a `TypeRep` as `Typeable` evidence.

The `TypeRep` pattern synonym brings a `Typeable` constraint into scope and can be used in place of `withTypeable`.

    f :: TypeRep a -> ..
    f rep = withTypeable {- Typeable a in scope -}

    f :: TypeRep a -> ..
    f TypeRep = {- Typeable a in scope -}

pattern TypeRep :: () => Typeable a => TypeRep a #

A explicitly bidirectional pattern synonym to construct a concrete representation of a type.

As an expression: Constructs a singleton `TypeRep a` given a implicit 'Typeable a' constraint:

    TypeRep @a :: Typeable a => TypeRep a

As a pattern: Matches on an explicit `TypeRep a` witness bringing an implicit `Typeable a` constraint into scope.

    f :: TypeRep a -> ..
    f TypeRep = {- Typeable a in scope -}

@since base-4.17.0.0

decTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> Either ((a :~~: b) -> Void) (a :~~: b) #

Type equality decision

@since base-4.19.0.0