Movatterモバイル変換
[0]ホーム
{-# LANGUAGE DeriveGeneric #-}{-# LANGUAGE TypeOperators #-}{-# LANGUAGE TypeFamilies #-}{-# LANGUAGE ScopedTypeVariables #-}{-# LANGUAGE GADTs #-}{-# LANGUAGE FlexibleInstances #-}{-# LANGUAGE StandaloneDeriving #-}{-# LANGUAGE NoImplicitPrelude #-}{-# LANGUAGE PolyKinds #-}{-# LANGUAGE RankNTypes #-}------------------------------------------------------------------------------- |-- Module : Data.Type.Coercion-- License : BSD-style (see the LICENSE file in the distribution)---- Maintainer : libraries@haskell.org-- Stability : experimental-- Portability : not portable---- Definition of representational equality ('Coercion').---- @since 4.7.0.0-----------------------------------------------------------------------------moduleData.Type.Coercion(Coercion(..),coerceWith,gcoerceWith,sym,trans,repr,TestCoercion(..))whereimportqualifiedData.Type.EqualityasEqimportData.MaybeimportGHC.EnumimportGHC.ShowimportGHC.ReadimportGHC.Base-- | Representational equality. If @Coercion a b@ is inhabited by some terminating-- value, then the type @a@ has the same underlying representation as the type @b@.---- To use this equality in practice, pattern-match on the @Coercion a b@ to get out-- the @Coercible a b@ instance, and then use 'coerce' to apply it.---- @since 4.7.0.0dataCoercionabwhereCoercion::Coercibleab=>Coercionab-- with credit to Conal Elliott for 'ty', Erik Hesselink & Martijn van-- Steenbergen for 'type-equality', Edward Kmett for 'eq', and Gabor Greif-- for 'type-eq'-- | Type-safe cast, using representational equalitycoerceWith::Coercionab->a->bcoerceWithCoercionx=coercex-- | Generalized form of type-safe cast using representational equality---- @since 4.10.0.0gcoerceWith::Coercionab->(Coercibleab=>r)->rgcoerceWithCoercionx=x-- | Symmetry of representational equalitysym::Coercionab->CoercionbasymCoercion=Coercion-- | Transitivity of representational equalitytrans::Coercionab->Coercionbc->CoercionactransCoercionCoercion=Coercion-- | Convert propositional (nominal) equality to representational equalityrepr::(aEq.:~:b)->CoercionabreprEq.Refl=Coercion-- | @since 4.7.0.0derivinginstanceEq(Coercionab)-- | @since 4.7.0.0derivinginstanceShow(Coercionab)-- | @since 4.7.0.0derivinginstanceOrd(Coercionab)-- | @since 4.7.0.0derivinginstanceCoercibleab=>Read(Coercionab)-- | @since 4.7.0.0instanceCoercibleab=>Enum(Coercionab)wheretoEnum0=CoerciontoEnum_=errorWithoutStackTrace"Data.Type.Coercion.toEnum: bad argument"fromEnumCoercion=0-- | @since 4.7.0.0derivinginstanceCoercibleab=>Bounded(Coercionab)-- | This class contains types where you can learn the equality of two types-- from information contained in /terms/. Typically, only singleton types should-- inhabit this class.classTestCoercionfwhere-- | Conditionally prove the representational equality of @a@ and @b@.testCoercion::fa->fb->Maybe(Coercionab)-- | @since 4.7.0.0instanceTestCoercion((Eq.:~:)a)wheretestCoercionEq.ReflEq.Refl=JustCoercion-- | @since 4.10.0.0instanceTestCoercion((Eq.:~~:)a)wheretestCoercionEq.HReflEq.HRefl=JustCoercion-- | @since 4.7.0.0instanceTestCoercion(Coerciona)wheretestCoercionCoercionCoercion=JustCoercion
[8]ページ先頭